Python开发环境之pyenv环境搭建
首先到Github上下载Pyenv相应的一键安装脚本, $curl-Lhttps://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer|bash 安装完毕,设置环境变量,设置环境变量,可以添加到个人家目录的.bashrc或.bash_profile及系统的全 局的/etc/profile, #Loadpyenvautomaticallybyadding #thefollowingto~/.bash_profile: exportPATH="/home/lavenliu/.pyenv/bin:$PATH" eval"$(pyenvinit-)" eval"$(pyenvvirtualenv-init-)" 设置完毕之后,可以在命令行进行验证, [lavenliu@VM_113_230_centos~]$.~/.bash_profile [lavenliu@VM_113_230_centos~]$pyenv pyenv20160726 Usage:pyenv<command>[<args>] Someusefulpyenvcommandsare: commandsListallavailablepyenvcommands localSetorshowthelocalapplication-specificPythonversion globalSetorshowtheglobalPythonversion shellSetorshowtheshell-specificPythonversion installInstallaPythonversionusingpython-build uninstallUninstallaspecificPythonversion rehashRehashpyenvshims(runthisafterinstallingexecutables) versionShowthecurrentPythonversionanditsorigin versionsListallPythonversionsavailabletopyenv whichDisplaythefullpathtoanexecutable whenceListallPythonversionsthatcontainthegivenexecutable See`pyenvhelp<command>'forinformationonaspecificcommand. Forfulldocumentation,see:https://github.com/yyuu/pyenv#readme 以上都没有问题。比如,安装一个3.5.2的版本Python, pyenvinstall3.5.2 如果下载速度慢的话,可以事先下载之,放到~/.pyenv/cache目录即可。修改~/.pyenv/plugins/python-build/share/python-build/3.5.2文件, cat~/.pyenv/plugins/python-build/share/python-build/3.5.2 #require_gcc install_package"openssl-1.0.2g""https://www.openssl.org/source/openssl-1.0.2g.tar.gz#b784b1b3907ce39abf4098702dade6365522a253ad1552e267a9a0e89594aa33"mac_openssl--ifhas_broken_mac_openssl install_package"readline-6.3""http://ftpmirror.gnu.org/readline/readline-6.3.tar.gz#56ba6071b9462f980c5a72ab0023893b65ba6debb4eeb475d7a563dc65cafd43"standard--ifhas_broken_mac_readline ifhas_tar_xz_support;then install_package"Python-3.5.2""~/.pyenv/cache/Python-3.5.2.tar.gz"ldflags_dirsstandardverify_py35ensurepip else install_package"Python-3.5.2""~/.pyenv/cache/Python-3.5.2.tar.gz"ldflags_dirsstandardverify_py35ensurepip fi 由于没有~/.pyenv/cache目录,进行手工创建, $mkdir~/.pyenv/cache 如果使用手工安装,则需要安装一些依赖, #yuminstall-ygccmakepatchgdbm-developenssl-develsqlite-develzlib-develbzip2-develreadline-devel 需要事先准备好Python-3.5.2.tar.gz的安装包,放到~/.pyenv/cache目录下。然后,在命令行直接使用pyenv install 3.5.2即可, $pyenvinstall3.5.2 安装完毕,使用version命令进行查看, pyenvversion 3.5.2(setby/home/lavenliu/.python-version) 至此,已经安装完毕。