1. 生成requirements.txt
pip freeze -> requirements.txt
此时生成的requirements.txt会在自己使用指令的路径里。
2. 安装requirements.txt
把requirements.txt复制到指令路径。
因为我是通过pycharm生成的requirements.txt,会附带一些信息,导致报错,ERROR: Could not install packages due to an OSError: [Errno 2]。把多余的信息删掉就可以。
删除前:
删除后:
删除后,新建一个环境,就可以安装了
pip install -r requirements.txt
感谢博主 https://blog.csdn.net/qq_42732137/article/details/122198522
3. pytorch特殊情况,OSError: [WinError 126] 找不到指定的模块
因为我是在清华源离线下载的gpu版本,虽然requirements.txt有安装包的信息,但是缺少cudatoolkit,然后就只能去官网重新下载一次
conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch
最后离线安装三个包就可以了,离线安装详情见https://blog.csdn.net/weixin_43868021/article/details/122083729
感谢博主 https://blog.csdn.net/qq_43115981/article/details/115168244
对于pytorch 2.0.1版本,指令为
conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.7 -c pytorch -c nvidia
4. pillow问题
ImportError: DLL load failed while importing _imaging: 找不到指定的模块。
把pillow卸载完,然后重装
参考https://blog.csdn.net/weixin_36815313/article/details/107614883