安装Anaconda过程
下载win10对应的Anaconda安装包
下载地址
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
使用gitbash里的wget下载
wget -c -P . https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2022.05-Windows-x86_64.exe
安装Anaconda
按部就班安装即可,过程有点慢。
添加环境变量
path里添加如下2个变量(假设安装路径是c:\opt\anaconda3),
c:\opt\anaconda3
c:\opt\anaconda3\Scripts
配置源(此处很多帖子博客都很坑,没说到点子上)
参考一个老哥的帖子
https://www.cnblogs.com/tianlang25/p/12433025.html
进入C:\Users\你的用户,写入一下内容到.condarc并保存,
ssl_verify: true
show_channel_urls: true
channels:
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
升级Anaconda
注意如果电脑开了代理,务必先关闭代理。
conda upgrade --all -y
Anaconda使用
查看环境
conda env list
创建环境
conda create -n py3813 python=3.8.13 -y
激活环境
conda init
重启打开命令行终端
conda activate py3813
每个环境都是独立的,可以使用pip安装所需的软件包
配置pip国内源(如果需要)
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
安装一些常用库(如果需要)
pip install --upgrade pip
c:\opt\anaconda3\envs\py3813\python.exe -m pip install --upgrade pip
pip install requests mysqlpy paramiko ipython numpy scipy opencv-python sanic sanic_cors
退出环境
conda deactivate
删除环境
conda remove -n env_name --all
删除单个镜像URL
conda config --remove channels your_url #你想移除的指定镜像路径
恢复默认的镜像源
conda config --remove-key channels
conda搜索包
conda search python | grep 3.8.13
常见问题FAQ
pip升级报错 ValueError: check_hostname requires server_hostname
关闭代理解决
pip升级报错 ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问
使用管理员终端进行执行(win+R进入黑窗口):python -m pip install --upgrade pip