python教程—无法从站点包目录通过pip加载安装的Python模块-Python实用宝典

python教程—无法从站点包目录通过pip加载安装的Python模块

我正在尝试安装和使用Evernote模块(https://github.com/evernote/evernote-sdk-python)。我运行pip install evernote,它说安装成功了。

我正在尝试安装和使用Evernote模块(https://github.com/evernote/evernote-sdk-python)。我运行pip install evernote,它说安装成功了。

我可以确认evernote模块存在于/usr/local/lib/python2.7/site-packages中。但是,当我尝试运行python -c“import evernote”时,我得到了以下错误:

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

这是我的.bash-profile的内容:

    [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* # Setting PATH for Python 3.3 # The orginal version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/3.3/bin:${PATH}" export PATH export PATH=$PATH:/usr/local/bin/

我有同样的问题与其他模块安装与pip。帮助吗?

编辑:我是一个超级新手,还没有编辑过那个.bash-profile文件。

编辑:python -c '导入系统;打印“n”.join(sys.path)'输出如下:

    /Library/Python/2.7/site-packages/setuptools-1.3.2-py2.7.egg /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7 /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC /Library/Python/2.7/site-packages

EDIT: I seemed to have made progress towards a solution by adding export PYTHONPATH=“/usr/local/lib/python2.7/site-packages” to my .bash_profile file. However, now when I run python -c 'from evernote.api.client import EvernoteClient' it tries to import oauth2, which fails with the same error. The ouath2 module is present in the module directory.

回答

/usr/bin/python是OS x附带的python的可执行文件。/usr/local/lib仅是用户安装程序的位置,可能来自Python.org或自制程序。因此,您混合了不同的Python安装,而更改Python路径只是针对不同安装安装的不同包的部分解决方案。

为了确保使用与特定python关联的pip,您可以运行python -m pip install < pkg >,或者查看路径上的pip是什么,或者它是符号链接的。

​Python实用宝典 (pythondict.com)
不只是一个宝典
欢迎关注公众号:Python实用宝典

本文由 Python实用宝典 作者:Python实用宝典 发表,其版权均为 Python实用宝典 所有,文章内容系作者个人观点,不代表 Python实用宝典 对观点赞同或支持。如需转载,请注明文章来源。
1

发表评论