为python设置virtualenv时出现错误的解释器错误

时间:2015-05-27 23:45:28

标签: python macos bash

我试图设置虚拟环境,但是当我尝试激活它时,我收到以下错误:

 virtualenv hello
-bash: /usr/local/bin/virtualenv: /usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/Resour: bad interpreter: No such file or directory

对可能出现的问题有任何疑问?我的$ 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

2 个答案:

答案 0 :(得分:1)

我建议你选择virtualenv包装 -

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
source /usr/local/bin/virtualenvwrapper_lazy.sh

http://virtualenvwrapper.readthedocs.org/en/latest/install.html#quick-start

答案 1 :(得分:-2)

看起来这个问题与我拥有的python的多个版本有关,其中一些版本导致了问题。干净的OS安装解决了这个问题。