在自定义Python上使用easy_install安装时遇到的问题

1 投票
3 回答
3852 浏览
提问于 2025-04-16 10:01

我有一台Mac电脑,所以我有机器自带的普通Python版本,还有我下载的新版本,这个新版本运行得很好。这个新版本在

$ which python
/Library/Frameworks/Python.framework/Versions/2.6/bin/python

Easy_install只在标准版本上能用:

$ which easy_install
/usr/bin/easy_install

于是我下载了setuptools-0.6c11-py2.6.egg,然后

$ cd Downloads/
$ sudo sh setuptools-0.6c11-py2.6.egg 
Password:

Processing setuptools-0.6c11-py2.6.egg
Copying setuptools-0.6c11-py2.6.egg to /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages
Adding setuptools 0.6c11 to easy-install.pth file
Installing easy_install script to /Library/Frameworks/Python.framework/Versions/2.6/bin
Installing easy_install-2.6 script to /Library/Frameworks/Python.framework/Versions/2.6/bin

Installed /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11

这似乎是有效的,

$ which easy_install
/Library/Frameworks/Python.framework/Versions/2.6/bin/easy_install

但是还有一些东西没有正常工作:

$ easy_install pymongoSearching for pymongo
Reading http://pypi.python.org/simple/pymongo/
Reading http://github.com/mongodb/mongo-python-driver
Best match: pymongo 1.9
Downloading http://pypi.python.org/packages/source/p/pymongo/pymongo-1.9.tar.gz#md5=12e12163e6cc22993808900fb9629252
Processing pymongo-1.9.tar.gz
Running pymongo-1.9/setup.py -q bdist_egg --dist-dir /var/folders/vm/vmoE5XqwH-yKiaMzAQS1vE+++TI/-Tmp-/easy_install-lRHv7W/pymongo-1.9/egg-dist-tmp-xFybXs
warning: no files found matching '*.h' under directory 'pymongo'
In file included from /usr/include/architecture/i386/math.h:626,
                 from /usr/include/math.h:28,
                 from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyport.h:235,
                 from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:58,
                 from bson/_cbsonmodule.c:23:
/usr/include/AvailabilityMacros.h:108:14: warning: #warning Building for Intel with Mac OS X Deployment Target < 10.4 is invalid.
In file included from /usr/include/architecture/i386/math.h:626,
                 from /usr/include/math.h:28,
                 from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyport.h:235,
                 from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:58,
                 from pymongo/_cmessagemodule.c:23:
/usr/include/AvailabilityMacros.h:108:14: warning: #warning Building for Intel with Mac OS X Deployment Target < 10.4 is invalid.
In file included from /usr/include/architecture/i386/math.h:626,
                 from /usr/include/math.h:28,
                 from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyport.h:235,
                 from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:58,
                 from bson/_cbsonmodule.c:23:
/usr/include/AvailabilityMacros.h:108:14: warning: #warning Building for Intel with Mac OS X Deployment Target < 10.4 is invalid.
zip_safe flag not set; analyzing archive contents...
Adding pymongo 1.9 to easy-install.pth file
error: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/easy-install.pth: Permission denied

然后当我打开Python时,我

import pymongo
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pymongo

我到底哪里做错了呢?

非常感谢!

3 个回答

0

虽然来得有点晚,但我在OSX 10.6.7上成功做到了以下这些:

easy_install pip

然后:

pip install pymongo
0

你有没有试过直接输入:easy_install pymongo 呢?

当你在IDLE中导入pymongo时,这个命令会返回什么呢?

2
error: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/easy-install.pth: Permission denied

你需要用管理员权限来运行 easy_install

撰写回答