Python 开发环境配置
2017-11-29 本文已影响87人
某尤
开发环境
pyenv
- 使用github仓库代码安装pyenv
mkdir ~/.pyenv
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
source ~/.bash_profile
Fish shell note: 添加到 ~/.config/fish/config.fish
status --is-interactive; and source (pyenv init -|psub)
- 使用离线包安装python
NOTE:国内下载很慢,建议使用 搜狐镜像 下载到本地进行安装
mkdir ~/.pyenv/cache
wget http://mirrors.sohu.com/python/$version/Python-$version.tar.xz -P ~/.pyenv/cache
- 安装你需要的 Python 版本
pyenv install $version
4.切换 Python 版本
pyenv local $version
pyenv-virtualenv
- 安装
git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bash_profile
source ~/.bash_profile
Fish shell note: 添加到 ~/.config/fish/config.fish
status --is-interactive; and source (pyenv virtualenv-init -|psub)
- 切换 virtualenv
pyenv virtualenv 3.6.3 venv36
pyenv virtualenvs
3.6.3/envs/venv36 (created from /home/username/.pyenv/versions/3.6.3)
* venv36 (created from /home/username/.pyenv/versions/3.6.3)
3.激活 virtualenv
pyenv activate <name>
pyenv deactivate
- 删除指定 virtualenv
pyenv uninstall <name>