简体   繁体   中英

sys_platform is not defined x64 Windows

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.

  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'}) 

To fix this error, I found that installing the 0.7.3 version of distribute fixed this. I had also upgraded setuptools and pip along the way (so they may be needed as well), but after upgrading distribute this error finally went away.

Try removing pip and distribute and setuptools, and then manually install pip using get-pip.py .

Then , download setuptools from here , extract -> go inside the extracted folder in command prompt and do python setup.py install

Then , download distribute from here , extract -> go inside the extracted folder in command prompt and do python setup.py install

I ran into this issue today myself, though on OSX. I had run --upgrade as well as trying to uninstall and reinstall it completely.

Eventually, though I went into my site packages, and saw a "correct" version of setuptools (18.1) AS WELL as an older lingering version of it (completely separate version 15.1 of it). Removing it all and reinstalling setuptools fresh fixed it for me.

Hopefully this helps someone else!

I had an old verison of distribute, which didn't correctly resolve dependencies. It was fixed with

C:\Users\cshucks>pip install --upgrade distribute
Collecting distribute
  Downloading distribute-0.7.3.zip (145kB)
    100% |################################| 147kB 375kB/s
Collecting setuptools>=0.7 (from distribute)
  Downloading setuptools-19.2-py2.py3-none-any.whl (463kB)
    100% |################################| 466kB 440kB/s
Installing collected packages: setuptools, distribute
  Found existing installation: setuptools 16.0
    Uninstalling setuptools-16.0:
      Successfully uninstalled setuptools-16.0
  Found existing installation: distribute 0.6.49
    Uninstalling distribute-0.6.49:
      Successfully uninstalled distribute-0.6.49
  Running setup.py install for distribute
Successfully installed distribute-0.7.3 setuptools-19.2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM