豆瓣源:(pip)
-i http://pypi.douban.com/simple/ –trusted-host pypi.douban.com
清华源:(conda 导入环境使用,channels配置)
channels:
-
conda-forge
-
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
-
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
-
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
-
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
-
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
方式1:
1. 创建虚拟环境
conda create -n xxxxx python = 3.x
2. 下载安装虚拟环境包
conda install xxxx
conda install -y xxxx(默认选y)
conda install -n xxxxx xxx(安装到指定环境)
pip install xxx
pip install -y xxx(默认yes)
pip install -n xxx(安装到指定环境)
3. 激活环境
conda activate xxxxx
确保python和pip都是当前环境的
which python:查看当前环境使用python解释器地址
pip -V:查看当前环境所使用的pip地址
方式2:
1. 安装环境
conda env export > xxxxx.yml:导出
conda env create -f xxxxxxx.yml:导入,创建环境
如果再yml文件中有需要使用pip命令安装的包,可将其copy至xxx.txt文档中,待环境安装完成再执行
pip install -r xxx.txt
pip install -r xxx.txt -i 国内镜像源地址
- 2. 报错管理
- 推荐:在安装环境之前将channels换成清华源,下载速度会快一些
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud//pytorch/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- 在下载的过程中可能会出现HTTP错误,通常是下载包过程中找不到包或者网速过慢导致失败(如下图,只下载一部分)。可参考以下解决方案:
报错信息会提示HTTP错误,后面会有一个下载网址,可以复制网址到google浏览器手动下载,下载完成后打包发送至服务器。
将报错的包从xxx.yml文件中删除,重新执行创建环境的命令,此时已经下载成功的包就不会重新下载,会直接解析安装,此时再激活环境,然后使用安装命令conda install /xxx/xx/安装包名(注意:使用绝对路径)
conda list :查看环境是否完整
3. 激活环境
conda activate xxxxx
确保python和pip都是当前环境的
which python:查看当前环境使用python解释器地址
pip -V:查看当前环境所使用的pip地址
Original: https://blog.csdn.net/weixin_42645047/article/details/126617132
Author: 大数据lsy
Title: Conda虚拟环境安装及问题解决方案
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/771762/
转载文章受原作者版权保护。转载请注明原作者出处!