1. 環境變量的配置(conda)
下面環境替換成自己的環境即可。
1.1 windows
將D:\anaconda\Scripts和D:\anaconda添加到環境變量中。
1.2 linux
打開:vim ~/.bashrc
添加:export PATH=~/anaconda3/bin:$PATH 到~/.bashrc中
然後:source ~/.bashrc
或者一行代碼即可:
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
2. pypi源的配置
2. 1 widows
windows下,直接在user目錄中創建一個pip目錄,如:C:\Users\xx\pip,新建文件pip.ini,內容如下:
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
2.2 linux
linux的文件在~/.pip/pip.conf中添加:
vim ~/.pip/pip.conf 添加進去即可。
[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host=pypi.douban.com
3. conda源的配置
3.1 windows(好像清華和中科院的不能用了)
- 通過 conda config 命令生成配置文件,cmd執行:
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
2. 執行命令:
conda config --set show_channel_urls yes
3. 此時,目錄 C:\Users<你的用戶名> 下就會生成配置文件.condarc
4. 修改上述配置文件,刪除上述配置文件 .condarc 中的第三行(即 -defaults),然後保存
5. 查看是否生效,通過命令 conda info 查看當前配置信息,內容如下,即修改成功,看channel URLs 字段內容:
6. 測試一下,安裝requests,執行命令:
conda install numpy
3.2 linux
命令行運行以下代碼即可:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
詳細查看:
conda的安裝與使用(2020-6-14更新)