anconda对python环境的搭建细节

一、创建一个 python为3.8.10的 环境 名称为 AIWangZhe

conda create --name AIWangZhe python=3.8.10

 

//激活 AIWangZhe环境

conda activate AIWangZhe

 

二、安装 其他各种环境包的细节

接入清华镜像的命令行 方法

https://mirror.tuna.tsinghua.edu.cn/help/anaconda/

Anaconda 安装包可以到 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 下载。

TUNA 还提供了 Anaconda 仓库与第三方源(conda-forge、msys2、pytorch等,查看完整列表)的镜像,各系统都可以通过修改用户目录下的 .condarc 文件。Windows 用户无法直接创建名为 .condarc 的文件,可先执行 conda config --set show_channel_urls yes 生成该文件之后再修改。

注:由于更新过快难以同步,我们不同步pytorch-nightlypytorch-nightly-cpuignite-nightly这三个包。

复制代码
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
复制代码

 

即可添加 Anaconda Python 免费仓库。

运行 

conda clean -i

 

 清除索引缓存,保证用的是镜像站提供的索引。

运行 

conda create -n myenv numpy

 

 测试一下吧。

 

 要用命令行的方式配置

因为Anaconda默认使用国外镜像源,下载速度相对较慢,为了节省时间提高效率,需要将源设置修改为国内镜像源,配置国内镜像源方法如下。

1.打开anaconda的prompt

如果不知道自己之前是否安装过多少镜像,可以用

conda config --show channels
1
显示镜像源,如果是新安装Anaconda则默认使用国外镜像源,它会显示

channels:
- defaults

 

如果想要删除重置,则执行

conda config --remove-key channels #删除所有的镜像源,恢复到默认
or
conda config --remove channels [urls] #删除指定的镜像源

 

2.在命令行下依次输入下面两行命令,配置国内镜像源:

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

conda config --set show_channel_urls yes

 

3.再输入以下命令验证一下是不是配置成功

conda config --show channels

 

显示以下输出内容则设置成功

channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- defaults

 

4.配置国内镜像源全部命令过程如下图所示

建议下面也全部添加,虽然有些可能用不到,但是实际包含比较冷门的包

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/
conda config --set show_channel_urls yes

 

5.附,国内常用的Anaconda镜像:

http://mirrors.aliyun.com/pypi/simple/ #阿里
https://pypi.tuna.tsinghua.edu.cn/simple/ #清华
http://pypi.douban.com/ #豆瓣
http://pypi.mirrors.ustc.edu.cn/ #中国科学技术大学

 

文章知识点与官方知识档案匹配,可进一步学习相关知识

 

 

1、安装 pytorch(CPU)版本

官网:https://pytorch.org/

conda install pytorch torchvision torchaudio cpuonly -c pytorch

 

换用国内阿里云的镜像

pip3 instal1 torch tcrcwision tarchaudio -i https://mirrors.aliyun.ccm/pypi/simp1e/

 

换成国内镜像  pip install +库名  + -i https://mirrors.aliyun.ccm/pypi/simp1e/

 

 

2、import cv2    报错解决办法

pip install opencv-python
pip3 install opencv-python

pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python

 

 

3.安装pyQt5

pip3 install pyqt5 -i https://pypi.douban.com/simple
pip3 install pyqt5-tools -i https://pypi.douban.com/simple 

 

posted @   Domefy  阅读(132)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示