sys_platform 未定义 x64 Windows

sys_platform is not defined x64 Windows

这困扰了我一段时间。我最近升级到 x64 Python,然后我开始收到此错误(例如 pip 安装)。

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

软件包安装正常,但我无法构建轮子。我尝试通过下载 zip 和 运行 python setup.py install 手动重新安装分发。安装得很好,很顺利。但是我还是遇到了上面的问题。

如何重新定义 sys_platform?

好的,我回滚到 x86 good ole 32 位 Python,但问题仍然存在。这真的很令人担忧,因为我无法在重新安装后重置它。我看了看markerlib,看起来很有前途,但我不知道如何安全地使用它。目前我几乎无法从 PyPI 安装 任何东西,所以我给点数以增加兴趣。

有什么帮助吗?我真的很想再次使用 PyPI。

我选择了所选答案,因为它最有可能解决问题。我自己已经回到 x86 Python,所以我无法自己测试。因此,我鼓励未来的访问者尝试这个答案,但我自己还没有能够测试它。

为了修复这个错误,我发现安装 0.7.3 版本的 distribute 修复了这个问题。我还一路升级了 setuptools 和 pip(因此可能也需要它们),但是在升级分发之后,这个错误终于消失了。

尝试删除 pip、distribute 和 setuptools,然后使用 get-pip.py 手动安装 pip。

然后,从 here 下载 setuptools,解压缩 -> 在命令提示符下进入解压缩的文件夹并执行 python setup.py install

然后,从 here 下载分发,解压缩 -> 在命令提示符下进入解压缩的文件夹并执行 python setup.py install

  1. 可能是一个错误。查看:https://bugs.python.org/
  2. 您可以手动检查 markers.py 文件并尝试修复它。我认为必须将对 sys_platform 的引用更改为 sys.platform
  3. 关于markerlib,你可以试试这个-

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

我今天自己 运行 进入了这个问题,虽然在 OSX 上。我有 运行 --upgrade 并尝试完全卸载并重新安装它。

最终,尽管我进入了我的网站包,并看到了 setuptools (18.1) 的 "correct" 版本以及较早的 lingering 版本它的(完全独立的版本 15.1)。全部删除并重新安装 setuptools 为我修复了它。

希望这对其他人有帮助!

我有一个旧版本的分发,它没有正确解决依赖关系。它已修复

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