Mac安装virtualenvwrapper时,
Operation not permitted: '/tmp/pip-P4ERUA-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'
解决方案:sudo pipinstallvirtualenvwrapper--upgrade --ignore-installed six
原因:
virtualenvwrapper需要依赖six,在安装six的时候发现系统已经有一个six-1.4.1,但是virtualenvwrapper需要six-1.9.0,于是想先卸载老版本的six,此时问题来了,发现没有权限卸载,此时我就纳闷,加上sudo,还是没权限。于是Google之,最终还是在万能的GitHub找到答案。系统用的是OS X El-Capitan版本,six-1.4.1是系统内置的packages,因系统集成保护你是没有权限去修改/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info目录的。因此在安装virtualenvwrapper的时候需要选择忽略six的安装
安装完成之后
配置环境变量
Install Steps:
sudo pip install virtualenv
Installs virtualenv (allows you to separate your envrionments)
sudo pip install virtualenvwrapper
Installs virtualenvwrapper (allows you to use the 'workon' command)
nano ~/.bash_profile
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
source ~/.bash_profile
Reloads the profile. Going forward you only need step 5 (to create new environments) and step 6 (to run environments)
mkvirtualenv my_env
This creates your virtual environment (this example is with 'my_env')
workon my_env
This lets you work on a specific environment (this example is with 'my_env')
创建环境
mkvirtualenv env1
mkvirtualenv env2
环境创建之后,会自动进入该目录,并激活该环境。
workon env1
workon env2
workon
deactivate
rmvirtualenv
项目将创建到PROJECT_HOME目录下,实际上相当于在某个目录下,建了一个环境。
mkproject
网友评论