【pyenv 】常用命令操作
一、命令介绍
$ pyenv --help Usage: pyenv <command> [<args>] Some useful pyenv commands are: activate Activate virtual environment commands List all available pyenv commands deactivate Deactivate virtual environment doctor Verify pyenv installation and development tools to build pythons. exec Run an executable with the selected Python version global Set or show the global Python version(s) help Display help for a command hooks List hook scripts for a given pyenv command init Configure the shell environment for pyenv install Install a Python version using python-build latest Print the latest installed or known version with the given prefix local Set or show the local application-specific Python version(s) prefix Display prefixes for Python versions rehash Rehash pyenv shims (run this after installing executables) root Display the root directory where versions and shims are kept shell Set or show the shell-specific Python version shims List existing pyenv shims uninstall Uninstall Python versions update Update pyenv, its plugins including the list of available versions --version Display the version of pyenv version Show the current Python version(s) and its origin version-file Detect the file that sets the current pyenv version version-name Show the current Python version version-origin Explain how the current Python version is set versions List all Python versions available to pyenv virtualenv Create a Python virtualenv using the pyenv-virtualenv plugin virtualenv-delete Uninstall a specific Python virtualenv virtualenv-init Configure the shell environment for pyenv-virtualenv virtualenv-prefix Display real_prefix for a Python virtualenv version virtualenvs List all Python virtualenvs found in `$PYENV_ROOT/versions/*'. whence List all Python versions that contain the given executable which Display the full path to an executable See `pyenv help <command>' for information on a specific command. For full documentation, see: https://github.com/pyenv/pyenv#readme
二、常用操作
1、查看可安装版本
pyenv install -l
2、查看已经安装的版本
pyenv versions
3、根据1选择版本安装
pyenv install 3.10.4
# 安装完后更新一下数据库:
pyenv rehash
4、设置python解释器版本
全局设置
pyenv global 3.10.4
本地设置
pyenv local 3.10.4
区别:
全局是系统层面, 本地是项目层面,不同项目可能会使用不同的版本
5、卸载python版本
pyenv uninstall 3.10.4
卸载安装的3.10.4版本
三、关于python下载源的问题
Ubuntu pyenv安装管理多版本python-CSDN博客
四、使用虚拟环境
1、创建虚拟环境
pyenv virtualenv 3.10.4 venv-3.10.4
2、查看虚拟环境
pyenv virtualenvs
3、激活虚拟环境
pyenv activate venv-3.10.4
4、退出虚拟环境
pyenv deactivate
5、删除虚拟环境
参考链接:
Ubuntu pyenv安装管理多版本python-CSDN博客
解决 externally-managed-environment问题_error: externally-managed-environment-CSDN博客