Easy_install 错误版本的python模块(Mac OS)

Easy_install 错误版本的python模块(Mac OS)

我在 Mac 上安装了 Python 2.7。在终端中输入“python”时,显示:

$ python
Python 2.7 (r27:82508, Jul  3 2010, 20:17:05) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

这里的 Python 版本是正确的。

但是当我尝试 easy_install 一些模块时。系统将安装 Python 版本 2.6 的模块,而这些模块无法导入到 Python 2.7。当然,我无法在代码中执行我需要的功能。以下是一个例子easy_install graphy

$ easy_install graphy
Searching for graphy
Reading pypi.python.org/simple/graphy/
Reading http://code.Google.com/p/graphy/
Best match: Graphy 1.0.0
Downloading http://pypi.python.org/packages/source/G/Graphy/Graphy- 1.0.0.tar.gz#md5=390b4f9194d81d0590abac90c8b717e0
Processing Graphy-1.0.0.tar.gz
Running Graphy-1.0.0/setup.py -q bdist_egg --dist-dir /var/folders/fH/fHwdy4WtHZOBytkg1nOv9E+++TI/-Tmp-/easy_install-cFL53r/Graphy-1.0.0/egg-dist-tmp-YtDCZU
warning: no files found matching '*.tmpl' under directory 'graphy'
warning: no files found matching '*.txt' under directory 'graphy'
warning: no files found matching '*.h' under directory 'graphy'
warning: no previously-included files matching '*.pyc' found under directory '.'
warning: no previously-included files matching '*~' found under directory '.'
warning: no previously-included files matching '*.aux' found under directory '.'
zip_safe flag not set; analyzing archive contents...
graphy.all_tests: module references __file__
Adding Graphy 1.0.0 to easy-install.pth file

Installed /Library/Python/2.6/site-packages/Graphy-1.0.0-py2.6.egg
Processing dependencies for graphy

Finished processing dependencies for graphy

因此它为 Python 2.6 安装了 graphy。

有人可以帮我吗?我只想将我的默认easy_installPython 版本设置为 2.7。

答案1

看来您安装的 setuptools 已经过时了。

如果您希望“easy_install”与更新的python版本匹配,请按照以下步骤操作:

这将安装新的“easy_install”可执行文件,与您当前的python版本兼容。

希望这可以帮助。

(更多详情请访问http://pypi.python.org/pypi/setuptools#cygwin-mac-os-x-linux-other

答案2

不确定这是否是您要找的,但是如果您输入命令+ia python file,您可以更改想要打开该文件的版本。

答案3

fjavieralba 的解决方案对我不起作用。有用的是使用 tarball 安装 easy_install。

  1. 下载 tarballhttp://pypi.python.org/pypi/setuptools#files(我将其放在/tmp/中)
  2. 使用命令提取tar -zxvf setuptools-0.6c11.tar.gz
  3. cd /setuptools-0.6c11
  4. 使用我想要 easy_install 支持的 python (2.7,在我的情况下是在 下) 进行安装/usr/local/bin/python

这是:

/usr/local/bin/python setup.py build
/usr/local/bin/python setup.py install

最后我可以使用 east_install 来获取我想要的包。对于 python2.7:

easy_install-2.7 *NAME*

或者,对于python 2.6:

easy_install-2.6 *NAME*

相关内容