简体   繁体   English

找不到Setuptools

[英]Setuptools not found

I am switching from Linux to OSX and when I run our build's setup.py script, I get an error message that contains the text 我从Linux切换到OSX,运行构建的setup.py脚本时,出现一条包含以下内容的错误消息:

This script requires setuptools version 0.6c7. 此脚本需要setuptools版本0.6c7。

I have tried several times to install setuptools, and have verified that the setuptools egg exists in /Library/Python/2.6/site-packages. 我已经尝试过几次安装setuptools的工作,并且已经验证了setupLiths egg在/Library/Python/2.6/site-packages中。 I have no idea why it is not being recognized. 我不知道为什么不被承认。

It is very common to have multiple versions of Python on OS X systems. 在OS X系统上拥有多个版本的Python非常普遍。 In recent releases of OS X, Apple has shipped two versions itself (in /usr/bin ). 在最新版本的OS X中,Apple本身提供了两个版本(在/usr/bin )。 You may have installed more recent versions using installers from python.org (which generally exist in /Library/Frameworks/Python.framework or using a package distributor like MacPorts (which install in /opt/local/Library/Frameworks/Python.framework ). Keep in mind that each version of Python requires its own copy of setuptools . 您可能使用python.org中的安装程序(通常存在于/Library/Frameworks/Python.framework或使用软件包分发程序(如MacPorts)(已安装在/opt/local/Library/Frameworks/Python.framework )安装了较新的版本。请记住,每个Python版本都需要自己的setuptools副本。

Since the site package path you report is /Library/Python/2.6/site-packages , it is most likely you have used the Apple-supplied Python 2.6.1 in OS X 10.6 to try to install a new version of setuptools . 由于您报告的站点包路径为/Library/Python/2.6/site-packages ,因此很可能您已使用Apple在OS X 10.6中提供的Python 2.6.1尝试安装新版本的setuptools Note that Apple already supplies setuptools for its Pythons (0.6c9 for 2.6.1 in 10.6); 请注意,Apple已经为其Python提供了setuptools (在10.6中为2.6.1的0.6c9); the corresponding easy_install commands are in /usr/bin . 相应的easy_install命令位于/usr/bin

$ /usr/bin/python2.6 -c 'import setuptools;print(setuptools.__file__,setuptools.__version__)'
('/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/setuptools/__init__.pyc', '0.6c9')

If you are using another non-Apple-supplied Python, follow the instructions to install a new version of setuptools (or Distribute ) making sure you are invoking the right version of Python. 如果您使用的是其他非Apple提供的Python,请按照说明安装新版本的setuptools (或Distribute ),以确保您调用的Python版本正确。 Check your shell PATH and which python to make sure. 检查您的shell路径以及要确保使用的which python

If that doesn't help, update your question with more information. 如果那没有帮助,请使用更多信息更新您的问题。

UPDATE: Based on your further comments, it seems something was amiss in your default site-packages directory. 更新:根据您的进一步评论,您的默认site-packages目录中似乎有些不对劲。 With that problem out of the way and having established that there is an Apple-supplied setuptools version 0.6c9 installed, it appears the package you are trying to install is looking for a specific, earlier version of setuptools, 0.6c7. 解决了这个问题,并确定已经安装了Apple提供的setuptools版本0.6c9,看来您要安装的软件包正在寻找特定的较早版本的setuptools 0.6c7。 If that is the case, you should first determine why that is and if it is necessary. 如果是这样,您应该首先确定原因,以及是否有必要。 Chances are that it is just an incorrect version specification in the package's setup.py file, ie using == rather than >= . 可能这只是软件包的setup.py文件中的版本说明不正确,即使用==而不是>= If you can, edit the setup.py so it can use a newer version. 如果可以,请编辑setup.py,使其可以使用较新的版本。 In the unlikely event that the package really does need that specific older version of setuptools (which may not even work with that version of Python or OS X), you could try installing the older version, like so: 万一该软件包确实确实需要特定版本的setuptools (甚至可能不适用于该版本的Python或OS X),则可以尝试安装该旧版本,如下所示:

$ sudo /usr/bin/easy_install-2.6 setuptools==0.6c7
$ /usr/bin/python2.6 -c 'import setuptools;print(setuptools.__file__,setuptools.__version__)'
('/Library/Python/2.6/site-packages/setuptools-0.6c7-py2.6.egg/setuptools/__init__.pyc', '0.6c7')

But you really should avoid doing that if at all possible as that will install another older version of easy_install in /usr/local/bin and could cause problems with installing and using other packages. 但是您实际上应该尽可能避免这样做,因为那样会在/usr/local/bin安装easy_install另一个旧版本,并可能导致安装和使用其他软件包的问题。

Have you tried to import setuptools in your setup.py script? 您是否尝试过在setup.py脚本中导入setuptools?

import setuptools

This solved my setuptool- ish build problems in the past. 这解决了我的setuptool- ISH建立在过去的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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