Skip to content

Python 虚拟环境

venv

创建虚拟环境

python -m venv [name]

一般 [name].venvvenv项目名称

python -m venv .venv

激活环境

source [name]/bin/activate

pyenv

GitHub - pyenv/pyenv: Simple Python version management

Switch between Python versions

To select a Pyenv-installed Python as the version to use, run one of the following commands:

E.g. to select the above-mentioned newly-installed Python 3.10.4 as your preferred version to use:

pyenv global 3.10.4

Now whenever you invoke python, pip etc., an executable from the Pyenv-provided 3.10.4 installation will be run instead of the system Python.

Using "system" as a version name would reset the selection to your system-provided Python.

conda