看起来我有多个python安装,这使得事情变得困难 - 例如pip将告诉我已经通过pip冻结安装了一个包,但是当试图在程序中使用它时,我得到一个它不存在的错误。以下是我运行的一些诊断测试:
>>> import sys
>>> sys.executable
'/usr/local/opt/python/bin/python2.7'
>>> sys.exec_prefix
'/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7'
>>> print '\n'.join(sys.path)
/usr/local/lib/python2.7/site-packages/setuptools-15.2-py2.7.egg
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python27.zip
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/site-packages
/Library/Python/2.7/site-packages/ipython-2.1.0-py2.7.egg
/Library/Python/2.7/site-packages/gnureadline-6.3.3-py2.7-macosx-10.9-intel.egg
/Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg
/Library/Python/2.7/site-packages
除了检查python的路径和一些常用工具外:
which easy_install
/usr/local/bin/easy_install
which python
/usr/local/bin/python
which pip
/usr/local/bin/pip
如何修复它,而不是干净地重新安装OS X?
编辑添加$ PATH和.bashrc信息:
我的$ PATH如下:
Users/me/workspace/google-cloud-sdk/bin:/usr/local/bin:/Users/me/workspace/google-cloud-sdk/bin:/urs/local/bin:/Users/me/workspace/google-cloud-sdk/bin:/urs/local/bin:/Users/me/workspace/google-cloud-sdk/bin:usr/local/python:usr/bin/python:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/texbin: No such file or directory
- 它返回错误的事实使我怀疑我以某种方式设置了我的.bash_profile错误。这些是我所做的唯一修改:
#Set architecture flags
export ARCHFLAGS="-arch x86_64"
#Ensure user-installed binaries take precedence
export PATH=/usr/local/bin:$PATH
#Load .bashrc if it exists
test -f ~/.bashrc && source ~/.bashrc
# The next line updates PATH for the Google Cloud SDK.
source '/Users/me/workspace/google-cloud-sdk/path.bash.inc'
# The next line enables bash completion for gcloud.
source '/Users/me/workspace/google-cloud-sdk/completion.bash.inc'
这是我的.bashrc:
# pip should only run if there is a virtualenv currently activated
export PIP_REQUIRE_VIRTUALENV=true
# cache pip-installed packages to avoid re-downloading
export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache
答案 0 :(得分:0)
无法找到解决问题的方法,因此最终做了一个干净的操作系统安装并设置了一个新的python开发环境。