这一直困扰着我。我最近升级到x64 Python,我开始收到此错误(示例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
包裹安装得很好,但我无法制造轮子。我尝试通过下载zip并运行python setup.py install
手动重新安装分发版。安装奇妙,没有任何障碍。但我仍然有上述问题。
如何重新定义sys_platform?
好吧,我回滚到x86 good ole 32 bit Python,我仍然有问题。这真的很令人担忧,因为重新安装后我无法重置它。我看了markerlib,看起来很有希望,但我不知道如何安全地使用它。目前我无法从PyPI安装很多任何,所以我给予积分以增加兴趣。
有任何帮助吗?我真的希望能够再次使用PyPI。
我选择了所选答案,因为最有可能来解决问题。我自己已经回到了x86 Python,所以我自己无法测试。因此,我鼓励未来的访问者尝试这个答案,但我自己无法对其进行测试。
答案 0 :(得分:7)
sys_platform
的引用必须更改为sys.platform
关于markerlib,你可以尝试一下 -
import markerlib
marker = markerlib.compile("sys.platform == 'win32'")
marker(environment=markerlib.default_environment(), override={'sys.platform':'win32'})
答案 1 :(得分:4)
要修复此错误,我发现安装0.7.3版本的分发修复此问题。我也一直在升级setuptools和pip(所以也可能需要它们),但升级后分发这个错误终于消失了。
答案 2 :(得分:4)
尝试删除pip并分发和设置工具,然后使用get-pip.py手动安装pip。
然后,从here下载setuptools,extract - &gt;在命令提示符下进入解压缩的文件夹并执行python setup.py install
然后,从here下载分发,提取 - &gt;在命令提示符下进入解压缩的文件夹并执行python setup.py install
答案 3 :(得分:1)
我今天遇到了这个问题,尽管在OSX上。我已经运行--upgrade
以及尝试完全卸载并重新安装它。
最终,虽然我进入了我的网站套餐,但看到了setuptools
(18.1)的“正确”版本,因为它是旧的延迟版本(完全独立的版本15.1)它)。删除所有内容并重新安装setuptools
为我修复它。
希望这有助于其他人!
答案 4 :(得分:0)
我有一个旧的分发版本,它没有正确解析依赖项。它是用
修复的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