修改conda镜像源
改为清华源
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
conda config --set show_channel_urls yes
换回默认源
conda config --remove-key channels
pip install opencv-python==4.5.4.60
清华镜像地址:
opencv-python https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/opencv-python/
opencv-contirb-python https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/opencv-contrib-python/
说明一下:比如opencv_python-3.4.1.15-cp36-cp36m-win_amd64.whl这个文件,cp36表示python3.6版本,这个版本要和anaconda里面的python版本保持一致
pip install opencv-python==4.5.4.60
pip install opencv-contrib-python==4.5.4.60
创建虚拟环境
命名为python36
conda create -n python python==
激活虚拟环境
conda activate python36
查看已有环境
conda env list
anaconda清华镜像
https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
解决conda An unexpected error has occurred.
输入
conda config --show-sources
找到.condrac文件,将其删除掉
删除虚拟环境
查看虚拟环境列表
conda env list
conda info --envs
conda remove -n xxxxx(名字) --all
解释:remove表示删除,-n是(name名字的缩写),xxxxx是要删除的虚拟环境的名字,最后的==–all== 如果不加上的话代表删除的是当前环境下的一个包,比如numpy等等,加上的话才是删除虚拟环境
加快solving
conda update -n base conda
conda install -n base conda-libmamba-solver
conda config --set solver libmamba
解决RemoveError: ‘requests’ is a dependency of conda and cannot be removed from conda’s operating environment.
问题:使用conda update conda
或其他conda安装\升级命令时,报如上错误
解决:执行一次 conda update --force conda
conda更新失败--更新后版本号不变
系统提示已成功,但更新后conda的版本号仍未变化
解决方案为加入参数--repodata-fn=repodata.json
。详见GitHub讨论
conda update -n base -c defaults conda --repodata-fn=repodata.json
查看cuda版本
命令行输入nvidia-smi
查看anaconda的版本
conda --version
anaconda创建虚拟环境报错(2种情况)
第一种:
anaconda创建虚拟环境报错:
UnsatisfiableError:
Note that strict channel priority may have removed packages required for satisfiability.
解决方法:
conda config --remove-key channels
conda config --append channels conda-forge --append channels bioconda --append channels defaults
第二种报错:
CondaHTTPError: HTTP 000 CONNECTION FAILED for url https://repo.anaconda.com/pkgs/main/win-64/current_repodata.json
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team.
'https://repo.anaconda.com/pkgs/main/win-64'
解决方法:
需要重新配置清华镜像源。————————————————
Anaconda查看、创建、切换虚拟环境
- 查看已有虚拟环境(两种都可以)
conda info --envs conda env list
- 创建新的虚拟环境
conda create -n newName python= activate newName
- 切换虚拟环境
conda activate name
查看gpu是否可以被pytorch使用
torch.cuda.is_available() print(torch.__version__)
【anaconda】conda创建、查看、删除虚拟环境(anaconda命令集
pip install tensorflow==2.3.0
pip --default-timeout=100 install setuptools==58.2.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
python setup.py install -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install torchvision==0.13.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install d2l==0.17.6 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install onnxruntime==1.11.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
ddddd
jiejiejie