pyenv是一款管理多个python版本的工具,可以便捷的切换使用的python版本,但是不支持windows环境,在windows环境需要使用pyenv-win
pyenv-win安装
官方介绍的安装方式比较多,在此主要记录一下我习惯的安装方式
- 下载pyenv-win,可以从github上下载,也可这里下载
- 创建文件加.pyenv, 将下载文件解压到此目录
- 根据解压后的文件路径设置环境变量PYENV, PYENV_HOME and PYENV_ROOT,path,参考如图所示
4. 验证是否成功,在控制台中执行pyenv --version
输出对应版本即表示成功
使用
pyenv的相关命令
C:\Users\Administrator>pyenv commands
--version
commands
duplicate
exec
export
global
help
install
latest
local
migrate
rehash
shell
shims
uninstall
update
version-name
version
versions
vname
whence
which
C:\Users\Administrator>pyenv version
3.12.2 (set by D:\Python\program\.pyenv-win\pyenv-win\version)
C:\Users\Administrator>pyenv versions
* 3.12.2 (set by D:\Python\program\.pyenv-win\pyenv-win\version)
3.8.9
各option说明
commands List all available pyenv commands
local Set or show the local application-specific Python version
latest Print the latest installed or known version with the given prefix
global Set or show the global Python version
shell Set or show the shell-specific Python version
install Install 1 or more versions of Python
uninstall Uninstall 1 or more versions of Python
update Update the cached version DB
rehash Rehash pyenv shims (run this after switching Python versions)
vname Show the current Python version
version Show the current Python version and its origin
version-name Show the current Python version
versions List all Python versions available to pyenv
exec Runs an executable by first preparing PATH so that the selected
Python version's `bin' directory is at the front
which Display the full path to an executable
whence List all Python versions that contain the given executable
注意:pyenv install
从 https://www.python.org/ftp/python获取安装包,可能会存在超时的情况,可以提前下载对应的安装包放到目录.pyenv-win\pyenv-win\install_cache\
下,就可直接进行安装了