首页 > 技术文章 > anconda对python环境的搭建细节

domefy 2021-12-12 19:54 原文

一、创建一个 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

 

 测试一下吧。

 

 

 

 

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 

 

推荐阅读