我正在尝试安装和使用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 'import sys; print "\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编辑:--我似乎通过将export PYTHONPATH=“/usr/local/lib/python2.7/site-packages”添加到.bash_profile文件中,在解决方案方面取得了进展。但是,现在当我运行python -c 'from evernote.api.client import EvernoteClient'时,它尝试导入oauth2,但同样的错误都失败了。ouath2模块存在于模块目录中。
发布于 2014-08-13 02:04:03
/usr/bin/python是OS附带的python的可执行文件。/usr/local/lib是一个仅供用户安装的程序的位置,可能来自Python.org或Homebrew。因此,您需要混合不同的Python安装,而更改python路径只是针对不同安装安装的不同包的部分解决方案。
为了确保使用与特定python相关联的pip,您可以运行python -m pip install <pkg>,或者查看路径上的pip是什么,或者是符号链接到什么。
发布于 2014-08-13 02:05:51
我想出来了!我增加了这一行:
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages
现在,我可以将存储在该目录中的模块导入到.bash_profile中。谢谢每一个回答的人。
发布于 2015-09-13 18:52:06
我遇到了类似的问题,它与/usr/local/lib/python2.7 2.7/site有关--包没有组和其他的读或写权限,它们属于root。这意味着只有根用户可以访问它们。
试试这个:
$ sudo chmod -R go+rX /usr/local/lib/python2.7/site-packageshttps://stackoverflow.com/questions/25276329
复制相似问题