我的mac上有几个版本的python。我想像python3一样是默认版本,也想使用virtualenv和virtualenvwrapper。
所以,我在~/.zshrc
alias python='python3'
我还在~/.zshrc
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
但是,当我运行mkvirtualenv
时,我收到以下错误:
▶ mkvirtualenv cv
mkvirtualenv:79: /usr/local/bin/virtualenv: bad interpreter: /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Ver: no such file or directory
即使我传递了python的版本,我也会得到同样的错误:
▶ mkvirtualenv -p /usr/local/bin/python3 cv
mkvirtualenv:79: /usr/local/bin/virtualenv: bad interpreter: /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Ver: no such file or directory
更多命令行输出显示版本和我已安装的内容:
▶ python --version
Python 3.5.0
~
▶ pip3.5 install virtualenv
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
~
▶ pip3.5 install virtualenvwrapper
Requirement already satisfied (use --upgrade to upgrade): virtualenvwrapper in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Requirement already satisfied (use --upgrade to upgrade): stevedore in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): virtualenv-clone in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): six>=1.9.0 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from stevedore->virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): pbr<2.0,>=1.6 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from stevedore->virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): argparse in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from stevedore->virtualenvwrapper)
~
▶ echo $VIRTUALENVWRAPPER_PYTHON
/usr/local/bin/python3
这是/usr/local/bin/virtualenv
有
▶ more /usr/local/bin/virtualenv
#!/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
# EASY-INSTALL-ENTRY-SCRIPT: 'virtualenv==12.0.5','console_scripts','virtualenv'
__requires__ = 'virtualenv==12.0.5'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('virtualenv==12.0.5', 'console_scripts', 'virtualenv')()
)
更新
~
▶ virtualenv --no-site-packages --distribute -p /usr/bin/python3.3 ~/.virtualenvs/pywork3
zsh: /usr/local/bin/virtualenv: bad interpreter: /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Ver: no such file or directory
答案 0 :(得分:3)
使用命令pyvenv
和python 3。
示例:
pyvenv venv
source venv/bin/activate