一河劝、安裝和使用pyenv
? ? 參照網(wǎng)址:
????????http://blog.froehlichundfrei.de/2014/11/30/my-transition-to-python3-and-pyenv-goodby-virtualenvwrapper.html
????????http://www.cnblogs.com/npumenglei/p/3719412.html
1.安裝pyenv 和pyenv virtualenv
? ? git clone git://github.com/yyuu/pyenv.git ~/.pyenv
? ? git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv
安裝完成后奖地,添加以下代碼到~/.zshenv或者~/.zsh_profile和悦,如果沒有安裝zsh的那么就將以下代碼復(fù)制到.bash_profile文件中:
# pyenv root
export PYENV_ROOT="$HOME/.pyenv"
# Add pyenv root to PATH
# and initialize pyenv
if [[ -d $PYENV_ROOT ]];then
? ? PATH="$PYENV_ROOT/bin:$PATH"
? ? # initialize pyenv
? ? eval "$(pyenv init -)"
? ? # initialize pyenv virtualenv
? ? eval "$(pyenv virtualenv-init -)"
fi
二、使用:
1.新建一個環(huán)境:pyenv virtualenv 3.5.1 Flask
2.設(shè)置某個版本的環(huán)境:pyenv local Flask
3.如果想要讓所有的都是用某一個環(huán)境:pyenv activate Flask
4.如果不使用了某一個環(huán)境:pyenv deactivate Flask就會換成系統(tǒng)環(huán)境了榜揖,
5.刪除這個虛擬環(huán)境:pyenv virtualenv-delete env271
三勾哩、問題:
????1.更新pyenv的版本:
????????進(jìn)入到.pyenv文件夾里面,輸入$git pull即可举哟,
????????更新數(shù)據(jù)庫思劳,pyenv rehash
????2.安裝python版本問題:
????????pyenv install 3.6.0
????????會報一下錯誤:
????????????Downloading openssl-1.0.2g.tar.gz...
????????????-> ????????????https://yyuu.github.io/pythons/b784b1b3907ce39abf4098702dade6365522a253ad1552e267a9a0e89594aa33
????????????Installing openssl-1.0.2g...
????????????BUILD FAILED (OS X 10.11.6 using python-build 1.0.8-2-gb7d89ba)
????????????Inspect or clean up the working tree at ????????????/var/folders/jb/x_x_0lz557q8kg81_c5t_9_40000gn/T/python-build.20170303110314.8781
????????????Results logged to /var/folders/jb/x_x_0lz557q8kg81_c5t_9_40000gn/T/python-build.20170303110314.8781.log
????????????Last 10 log lines:
????????????Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
????????????Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
這是因為沒有配置Xcode的原因:輸入:sudo xcodebuild -license accept即可