首页 > 其他分享 >pyenv 的安装和使用 记录一下避免自己下次用时忘了

pyenv 的安装和使用 记录一下避免自己下次用时忘了

时间:2022-11-27 11:08:57浏览次数:59  
标签:virtualenv 下次 install python 用时 pyenv https 版本


1.安装和删除和更新(参考 ​​https://github.com/pyenv/pyenv-installer​​ )

Install:
$ curl https://pyenv.run | bash
pyenv.run redirects to the install script in this repository and the invocation above is equivalent to:

$ curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
Restart your shell so the path changes take effect:

$ exec $SHELL
You can now begin using pyenv.

If you need, export USE_GIT_URI to use git:// instead of https:// for git clone.

Update:
$ pyenv update
Uninstall:
pyenv is installed within $PYENV_ROOT (default: ~/.pyenv). To uninstall, just remove it:

$ rm -fr ~/.pyenv
then remove these three lines from .bashrc:

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
and finally, restart your shell:

$ exec $SHELL

2.使用 常用命令

pyenv commands  查看pyenv命令

pyenv install --list #查看可安装的python版本
pyenv versions #查看已安装版本
pyenv version #查看当前使用的python版本
pyenv install -v 版本号 #安装python
pyenv rehash #刷新python已安装列表
pyenv uninstall 版本号 #删除python

pyenv virtualenv 已有版本环境名名 新版本环境名 #按已有版创建新的python环境(调用virtualenv,python3 自带了virtualenv,py2要自行装)

pyenv global 版本号 #设置当前全局python版本
pyenv local 版本号 #设置当前目录局部python版本,以后进入目录就会自动切换到这个版本
pyenv local --unset #取消局部python版本设置,或者删除当前目录下的.python-version文件

下载非常 慢怎么破?

pyenv淘宝镜像源加速:https://npm.taobao.org/mirrors/python/
下载需要的版本放到~/.pyenv/cache文件夹下面
然后执行 env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 版本号 安装对应的python版本

PS: 在mac下 pyenv install python 时一定要加上 env PYTHON_CONFIGURE_OPTS="--enable-framework", 否则会有很多坑,pyinstall可能打包了就是不能运行, wxpython 应用下面报错

This program needs access to the screen. Please run with a

Framework build of python, and only when you are logged in

on the main display of your Mac.

加了 enable-framework 安装后,明显的区别就是会在应用程序里多了python.app和IDLE.app. 我猜测可能是不加 enable-framework安装,会少装了窗口体系的支持。

pyenv 的安装和使用 记录一下避免自己下次用时忘了_pyenv

更细节的分析参考:​​https://wiki.wxpython.org/wxPythonVirtualenvOnMac​

 

ps: 如果是 brew 安装的 pyenv,可能没有默认装 pyenv-virtualenv

参考 https://github.com/pyenv/pyenv-virtualenv 安装。

或者都用brew安装更简

brew install pyenv

brew install pyenv-virtualenv

标签:virtualenv,下次,install,python,用时,pyenv,https,版本
From: https://blog.51cto.com/fangkailove/5889816

相关文章