昨天安装好了vscode,今天配置它的环境来运行yolo。
首先在anaconda里创建一个新的环境——pytorch,并激活环境:
conda create -n pytorch python==3.6 #环境名:pytorch,py版本3.6
activate pytorch
之后配置下载源
# 配置国内源,方便安装Numpy,Matplotlib等
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
# 配置国内源,安装PyTorch用
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
# 显示源地址
conda config --set show_channel_urls yes
但是执行显示源地址后,并没有出现源地址。接下来安装pytorch1.2,显示:
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
但是之后安装模块时并不成功,执行
conda clean --packages --tarballs
#再重新执行pytorch安装命令
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0
清除包这一步费时有点长,但是,重新执行pytorch安装命令,仍然是同样的结果,我先去运行了train.py,提示:
ModuleNotFoundError: No module named 'cv2'
搜索后发现要安装opencv-python,希望可以成功
anaconda search -t conda opencv-python
conda install -c https://api.anaconda.org//wheeler-microfluidics opencv-python
但是……,失败了:
(pytorch) C:\Users\ACER>conda install opencv-python
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- opencv-python
Current channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/noarch
- https://repo.anaconda.com/pkgs/main/win-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/win-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://repo.anaconda.com/pkgs/msys2/win-64
- https://repo.anaconda.com/pkgs/msys2/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
网上搜索之后,执行如下命令:
anaconda search -t conda opencv-python
结果:
(pytorch) C:\Users\ACER>anaconda search -t conda opencv-python
Using Anaconda API: https://api.anaconda.org
Packages:
Name | Version | Package Types | Platforms | Builds
------------------------- | ------ | --------------- | --------------- | ----------
fastai/opencv-python-headless | 4.5.1.48 | conda | linux-64, win-64, osx-64 | py37_0, py36_0, py38_0
: Wrapper package for OpenCV python bindings.
fastchan/opencv-python-headless | 4.5.1.48 | conda | linux-64, win-64, osx-64 | py37_0, py36_0, py38_0
: Wrapper package for OpenCV python bindings.
khamutov/opencv-python-headless | 4.3.0.36 | conda | linux-ppc64le | py37_3
: Power9 build for OpenCV
ohsu-comp-bio/opencv-python-headless | 4.5.1.48 | conda | linux-64, osx-64 | py37hb2a4cfb_1, py37hbeab489_0, py37hef7ab6a_1
: opencv python headless
rsignell/opencv-python | 2.4.9 | conda | win-32 | np18py27_0
wheeler-microfluidics/opencv-python | 3.1.0.3 | conda | win-32 | 0
Found 6 packages
Run 'anaconda show <USER/PACKAGE>' to get installation details
选择 wheeler-microfluidics/opencv-python,斜杠/换成空格:
conda install -c https://api.anaconda.org//wheeler-microfluidics opencv-python
又报错了:
(pytorch) C:\Users\ACER>conda install -c https://api.anaconda.org//wheeler-microfluidics opencv-python
Collecting package metadata (current_repodata.json): failed
UnavailableInvalidChannel: The channel is not accessible or is invalid.
channel name: wheeler-microfluidics
channel url: https://api.anaconda.org/wheeler-microfluidics
error code: 404
You will need to adjust your conda configuration to proceed.
Use `conda config --show channels` to view your configuration's current state,
and use `conda config --show-sources` to view config file locations.
检查设置后,发现只有之前配置的几个通道:
(pytorch) C:\Users\ACER>conda config --show channels
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- defaults
(pytorch) C:\Users\ACER>conda config --show-source
==> C:\Users\ACER\.condarc <==
ssl_verify: True
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- defaults
show_channel_urls: True
尝试了其他方法下载cv2,明天再写。