Python – sys_platform is not defined x64 Windows

pippython

This has been bugging me for a little while. I recently upgraded to x64 Python, and I started getting this error (example pip install).

C:\Users\<uname>\distribute-0.6.35>pip install python-qt
Collecting python-qt
  Downloading python-qt-0.50.tar.gz
Building wheels for collected packages: python-qt
  Running setup.py bdist_wheel for python-qt
  Complete output from command C:\Python27\python.exe -c "import setuptools;__file__='c:\\users\\<uname>\\appdata\\local\\t
emp\\pip-build-vonat7\\python-qt\\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bd
ist_wheel -d c:\users\<uname>\appdata\local\temp\tmpghy5gtpip-wheel-:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "c:\users\<uname>\appdata\local\temp\pip-build-vonat7\python-qt\setup.py", line 11, in <module>
      packages=['Qt'],
    File "C:\Python27\lib\distutils\core.py", line 137, in setup
      ok = dist.parse_command_line()
    File "C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg\setuptools\dist.py", line 232, in parse_command_line
      result = _Distribution.parse_command_line(self)
    File "C:\Python27\lib\distutils\dist.py", line 467, in parse_command_line
      args = self._parse_command_opts(parser, args)
    File "C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg\setuptools\dist.py", line 558, in _parse_command_opts
      nargs = _Distribution._parse_command_opts(self, parser, args)
    File "C:\Python27\lib\distutils\dist.py", line 523, in _parse_command_opts
      cmd_class = self.get_command_class(command)
    File "C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg\setuptools\dist.py", line 362, in get_command_class
      ep.require(installer=self.fetch_build_egg)
    File "C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg\pkg_resources.py", line 2027, in require
      working_set.resolve(self.dist.requires(self.extras),env,installer))
    File "C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg\pkg_resources.py", line 2237, in requires
      dm = self._dep_map
    File "C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg\pkg_resources.py", line 2466, in _dep_map
      self.__dep_map = self._compute_dependencies()
    File "C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg\pkg_resources.py", line 2499, in _compute_dependencies
      common = frozenset(reqs_for_extra(None))
    File "C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg\pkg_resources.py", line 2496, in reqs_for_extra
      if req.marker_fn(override={'extra':extra}):
    File "C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg\_markerlib\markers.py", line 109, in marker_fn
      return eval(compiled_marker, environment)
    File "<environment marker>", line 1, in <module>
  NameError: name 'sys_platform' is not defined

  ----------------------------------------
  Failed building wheel for python-qt
Failed to build python-qt
Installing collected packages: python-qt
  Running setup.py install for python-qt
Successfully installed python-qt-0.50

The package was installed fine, but I cannot build wheels. I tried re-installing distribute manually by downloading a zip and running python setup.py install. That installed wonderfuly, without a hitch. But I still have the above problem.

How can I re-define sys_platform?

Alright, I rolled back to x86 good ole 32 bit Python, and I still have the problem. This is really concerning, because I cannot reset this after re-installing. I looked at markerlib, which looks promising, but I don't know how to use it safely. Currently I am unable to install pretty much anything from PyPI, so I am giving points to increase interest.

Any help? I really want to be able to use PyPI again.

I chose the selected answer as it is the most likely to solve the problem. I myself have moved back to x86 Python, so I cannot test this myself. Therefore, I encourage future visitors to try this answer, but I have not myself been able to test it.

Best Solution

  1. Might be a bug. Check out: https://bugs.python.org/
  2. You can manually check the markers.py file and try to fix it. I think there would a reference to sys_platform that has to be changed to sys.platform
  3. Regarding markerlib, you can try this out-

    import markerlib
    marker = markerlib.compile("sys.platform == 'win32'")
    marker(environment=markerlib.default_environment(), override={'sys.platform':'win32'})