首页 > 系统服务 > 详细

MacOS安装并使用pyenv

时间:2020-03-19 16:11:46      阅读:53      评论:0      收藏:0      [点我收藏+]

进入github官方地址下载pyenvpyenv-virtualenv代码

 $ 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

Zsh note: Modify your ~/.zshenv file instead of ~/.bash_profile.

Add pyenv init to your shell to enable shims and autocompletion. Please make sure eval "$(pyenv init -)" is placed toward the end of the shell configuration file since it manipulates PATH during the initialization.

$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bash_profile

Zsh note: Modify your ~/.zshenv file instead of ~/.bash_profile.

Restart your shell so the path changes take effect. You can now begin using pyenv.

exec "$SHELL"

Install Python versions into $(pyenv root)/versions. For example, to download and install Python 3.7.3, run:

$ pyenv install 3.7.3

NOTE: If you need to pass configure option to build, please use CONFIGURE_OPTS environment variable.

NOTE: If you want to use proxy to download, please use http_proxy and https_proxy environment variable.

NOTE: If you are having trouble installing a python version, please visit the wiki page about Common Build Problems

# 查看相应python环境
$ pyenv versions

# 创建某个项目所需的python环境
$ pyenv virtualenv 3.7.5 guanshu

# 激活项目所需的环境
$ pyenv activate guanshu

# 退出项目所在的环境
$ pyenv deactivate guanshu

MacOS安装并使用pyenv

原文:https://www.cnblogs.com/liuhuan086/p/12524854.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!