conda常用命令

conda create --name myenv 这将在当前环境中创建一个名为myenv的虚拟环境。可以将--name参数替换为你想要的虚拟环境名字

conda create --name myenv python=3.7

除了创建虚拟环境,我们还可以指定所需的Python版本。在上述示例中,我们创建了一个名为myenv的虚拟环境,并使用了Python

 

conda env list 列出环境列表

conda activate [环境名]  切换到[环境名]这个环境下

conda install [包名]  conda安装包

conda uninstall [包名] 卸载包

 

conda install -c conda-forge 包名

从conda-forge中安装包 有时默认频道中没有包,可以从conda-forge中找

 

conda clean --all 清理缓存、tarball文件以及未使用的文件

什么时候用?

之前安装包的时候进度条卡住不动了,于是我直接关闭了命令行重新安装,结果报错

CondaVerificationError: The package for qt-main located at C:\Users\cheng_zhid\.conda\pkgs\qt-main-5.15.2-he8e5bd7_7 appears to be corrupted. The path 'Library/translations/qtxmlpatterns_zh_TW.qm' specified in the package manifest cannot be found.

问ai说可能是包缓存中的文件损坏了。你可以通过清理缓存来强制 Conda 重新下载包。

然后用clean --all清理后重新安装

 

conda报错:

The current user does not have write permissions to the target environment.
environment location: D:\anaconda3

解决方法:关掉命令行后以管理员身份运行重新打开

 

换源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

conda config --set show_channel_urls yes

 

查看源

conda config --show channels

 

添加源

conda config --add channels 要添加的源 

 

上面那个换源好像不是狠管用

下面一个管用的 参考文章:https://blog.csdn.net/CSDN222111/article/details/141642601

conda config --set show_channel_urls yes
执行完后在C:\Users\用户名 下面有一个.condarc文件

打开后编辑

 

channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
deepmodeling: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/

 

然后运行

conda clean -i # 清除索引

 

 

# 添加清华源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

# 添加阿里云镜像源
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/free/
conda config --add channels https://mirrors.aliyun.com/anaconda/pkgs/main/

# 添加中科大源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/



# (可选)设置搜索时显示通道地址
conda config --set show_channel_urls yes

 


__EOF__

本文作者cheng_zhi
本文链接https://www.cnblogs.com/chengzhid/p/18622241.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   cheng_zhi  阅读(24)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示