本文主要是介绍pyenv-win管理windows上多个版本python,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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
whichC:\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 commandslocal Set or show the local application-specific Python versionlatest Print the latest installed or known version with the given prefixglobal Set or show the global Python versionshell Set or show the shell-specific Python versioninstall Install 1 or more versions of Pythonuninstall Uninstall 1 or more versions of Pythonupdate Update the cached version DBrehash Rehash pyenv shims (run this after switching Python versions)vname Show the current Python versionversion Show the current Python version and its originversion-name Show the current Python versionversions List all Python versions available to pyenvexec Runs an executable by first preparing PATH so that the selected Python version's `bin' directory is at the frontwhich Display the full path to an executablewhence List all Python versions that contain the given executable
注意:pyenv install
从 https://www.python.org/ftp/python获取安装包,可能会存在超时的情况,可以提前下载对应的安装包放到目录.pyenv-win\pyenv-win\install_cache\
下,就可直接进行安装了
这篇关于pyenv-win管理windows上多个版本python的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!