主题
虚拟环境
创建虚拟环境
shell
python -m venv flask-env
指定python版本,比如 /usr/local/bin/python3 对应的版本是3.10.9
会出现一个名为flask-env
的子目录,这里就是一个全新的虚拟环境,包含Python解释器
shell
wangxiaomin@wxmgcs-3 flask-env % tree -L 2
.
├── bin
│ ├── Activate.ps1
│ ├── activate
│ ├── activate.csh
│ ├── activate.fish
│ ├── pip
│ ├── pip3
│ ├── pip3.10
│ ├── python -> /Users/wangxiaomin/opt/anaconda3/envs/py310/bin/python
│ ├── python3 -> python
│ └── python3.10 -> python
├── include
├── lib
│ └── python3.10
└── pyvenv.cfg
4 directories, 11 files
查看虚拟环境配置
% cat pyvenv.cfg
home = /Users/wangxiaomin/opt/anaconda3/envs/py310/bin
include-system-site-packages = false
version = 3.10.16
进入虚拟环境
shell
source flask-env/bin/activate
退出环境
shell
deactivate
删除虚拟环境
shell
rm -rf flask-env
安装Flask
shell
pip install flask
查看安装包
shell
(flask-env) (base) wangxiaomin@wxmgcs-3 flask-env % pip freeze
blinker==1.9.0
click==8.1.8
Flask==3.1.0
itsdangerous==2.2.0
Jinja2==3.1.5
MarkupSafe==3.0.2
Werkzeug==3.1.3
(flask-env) (base) wangxiaomin@wxmgcs-3 flask-env % pip list
Package Version
------------ -------
blinker 1.9.0
click 8.1.8
Flask 3.1.0
itsdangerous 2.2.0
Jinja2 3.1.5
MarkupSafe 3.0.2
pip 23.0.1
setuptools 65.5.0
Werkzeug 3.1.3
[notice] A new release of pip is available: 23.0.1 -> 24.3.1
[notice] To update, run: pip install --upgrade pip