简体   繁体   English

修复多个python安装

[英]Fix multiple python installations

It looks like I have multiple python installations, which are making things difficult -- eg pip will tell me that a package has been installed through pip freeze, but when attempting to use it within a program, I get an error that it does not exist. 看来我有多个python安装程序,这使事情变得困难-例如pip会告诉我某个软件包是通过pip冻结安装的,但是当尝试在程序中使用它时,出现错误,提示它不存在。 Here are a few diagnostic tests I've run: 这是我运行的一些诊断测试:

>>> 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

As well as checking the path for python and some common tools: 以及检查python和一些常用工具的路径:

which easy_install
/usr/local/bin/easy_install
which python
/usr/local/bin/python
which pip
/usr/local/bin/pip

How can I fix it, short of doing a clean re-install of OS X? 如果不重新安装OS X,该如何解决?

Edited to add $PATH and .bashrc info: 编辑以添加$ PATH和.bashrc信息:

My $PATH is as follows: 我的$ 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

-- the fact that it is returning an error makes me suspect that I've set up my .bash_profile wrong somehow. -它返回错误的事实使我怀疑我以某种方式设置的.bash_profile错误。 These are the only modifications I have made: 这些是我所做的唯一修改:

#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' 

And this is my .bashrc: 这是我的.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

无法找到解决方法,因此最终进行了干净的操作系统安装并建立了新的python开发环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM