python 基础 | 虚拟环境搭建全流程

首先,建立 python 虚拟环境 test_env:

python3 -m venv test_env
# 激活虚拟环境
source ./test_env/bin/activate # linux
venv/Scripts/activate # windows
# 停止虚拟环境
deactivate # windows / linux

然后,安装所需的依赖包。

pytorch 会麻烦一点,我们先装 pytorch(详见 pytorch.org):

# cpu 版
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu

再装其他包,直接使用 requirements.txt:

# 如果安装太慢,需要 pip 换源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/
# pip 使用 requirements.txt
pip install -r requirements.txt

requirements.txt 的格式:

gym>=0.21
# torch>=1.11
numpy>1.16.0 # https://github.com/numpy/numpy/issues/12793
pandas>=0.24.2
scipy>=1.4.1
scikit-learn>=0.21.2
matplotlib>=3.1.0
wandb>=0.12.0
jupyter>=1.0.0
h5py>=2.9.0
pygame>=2.1.0
typing_extensions>=4.0
cloudpickle
importlib-metadata~=4.13
pillow
tqdm
isort>=5.0
rich
psutil
flake8>=3.8
black
pytest
pytest-cov
pytype
opencv-python
openpyxl
func_timeout

本文作者:MoonOut

本文链接:https://www.cnblogs.com/moonout/p/16997694.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   MoonOut  阅读(179)  评论(1编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 Sibelius: Violin Concerto in D Minor, Op. 47:III. Allegro, ma non tanto Jascha Heifetz / Chicago Symphony Orchestra
Sibelius: Violin Concerto in D Minor, Op. 47:III. Allegro, ma non tanto - Jascha Heifetz / Chicago Symphony Orchestra
00:00 / 00:00
An audio error has occurred.