【python】基础学习(八)虚拟环境创建


创建虚拟环境的命令

python3 -m venv 20211121venv

[root@VM-4-12-centos pythonproject]# python3 -m venv 20211121venv
[root@VM-4-12-centos pythonproject]# ls
20211121venv
[root@VM-4-12-centos pythonproject]# cd 20211121venv/
[root@VM-4-12-centos 20211121venv]# ls
bin  include  lib  lib64  pyvenv.cfg

激活虚拟环境

[root@VM-4-12-centos bin]# source activate
(20211121venv) [root@VM-4-12-centos bin]# pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
pip (9.0.3)
setuptools (39.2.0)
You are using pip version 9.0.3, however version 21.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(20211121venv) [root@VM-4-12-centos bin]# 

退出虚拟环境

(20211121venv) [root@VM-4-12-centos bin]# deactivate
[root@VM-4-12-centos bin]#