![](/img/trans.png)
[英]Trouble installing “distribute”: NameError: name 'sys_platform' is not defined
[英]sys_platform is not defined x64 Windows
这一直困扰着我。 我最近升级到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,所以我自己无法测试。 因此,我鼓励未来的访客尝试这个答案,但我没有能够测试它。
sys_platform
的引用必须更改为sys.platform
关于markerlib,你可以试试这个 -
import markerlib marker = markerlib.compile("sys.platform == 'win32'") marker(environment=markerlib.default_environment(), override={'sys.platform':'win32'})
为了解决这个错误,我发现安装0.7.3版本的分发修复了这个问题。 我也一路上升级了setuptools和pip(所以也可能需要它们),但升级后分发这个错误终于消失了。
尝试删除pip并分发和setuptools,然后使用get-pip.py手动安装pip。
然后,从这里下载setuptools,解压 - >在命令提示符下进入解压缩文件夹并执行python setup.py install
然后,从这里下载分发,解压缩 - >在命令提示符下进入解压缩文件夹并执行python setup.py install
我今天遇到了这个问题,尽管在OSX上。 我已经运行--upgrade
以及尝试卸载并完全重新安装它。
最后,虽然我走进我的网站的包,看到一个“正确”的版本setuptools
(18.1),以及它的一个较老版本的缠绵 (完全独立版吧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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.