一、Pytorch环境配置
1、根据要运行的代码来选择安装哪个版本的pytorch和python,依据代码配置相关的环境;
2、环境配置
例如:我要运行的一个代码环境是:pytorch 1.5.0 和python 3.6.5
conda create -n pytorch1.5 python=3.6.5
其中pytorch1.5是为配置的环境取的环境名;
3、激活环境
conda activate pytorch1.5
4、安装pytorch
进入pytorch官网,选择的是pytorch 1.5.0,无GPU版本;在已更换镜像源的情况下,删除后面的
-c pytorch
conda install pytorch==1.5.0 torchvision==0.6.0 cpuonly -c pytorch
5、相关库的安装
例如:CV2库的安装
pip insatll opencv-python
若出现错误:Cache entry deserialization failed, entry ignored;
Command "python setup.py egg_info" failed with error code 1 in
则更新pip
python -m pip install --upgrade pip
二、环境配置时出现如下错误:
ProxyError: conda cannot proceed due to an error in your proxy configuration.Check for typos and other configuration errors in any '.netrc' file in your home directory,any environment variables ending in '_PROXY', and any other system-wide proxy configuration settings.
修改方法:
1、在Internet中打开“Internet选项”——>连接——>局域网设置——>把“为LAN使用代理服务器”的勾去掉。
2、按Win+R快捷键,输入regedit,打开注册表编辑器找到HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Internet Settings分支,把它下面以 Proxy 打头的键值对(如ProxyEnable,ProxyOverride,ProxyServer等)全部删除。