conda 包管理工具及换源

发布于:2023-03-12 ⋅ 阅读:(60) ⋅ 点赞:(0)

conda 包管理工具

列出环境

conda env list  

创建环境,并指定python 版本,在最后添加python=3.7

conda create --name demo_env3.7 python=3.7

进入环境

conda activate demo_env

退出环境

conda deactivate 

移除环境,--all表示把这个环境下的所有的包删除了

conda remove --name demo_env3.7 --all

一、windows及其他系统conda换源方法:
参见:https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

二、windows及其他系统pip换源方法:

2.1 Windows

2.1.1 临时使用:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple {包名}

2.1.2 永久使用:
第一步: 在C:\Users\Administrator 目录下 创建pip文件夹
第二步:在第一步创建的文件夹下(C:\Users\Administrator\pip)创建pip.ini文件
第三步:记事本编辑保存pip.ini文件内容为以下部分:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn

2.2 MacOS系统
2.2.1 临时使用:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple {包名}
2.2.2 永久使用:

执行以下语句

cd ~
mkdir .pip
cd .pip
vi pip.conf

pip.conf写入

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn

保存pip.conf

2.3 Ubuntu

cd ~
mkdir .pip

直接新建并编辑pip.conf:

sudo nano ~/.pip/pip.conf

改为以下内容(这里用的清华源,也可以试一下阿里、豆瓣等源):

[global]
index-url = https://pypi.tuna.tsinghua.ed...
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn

  1. 在jupyter 中注册这个环境
conda activate python_38-pytorch_1.7.0
conda install ipykernel

python -m ipykernel install --user --name python_38-pytorch_1.7.0 --display-name "Python38-pytorch_1.7.0"
#其中python_38-pytorch_1.7.0 是环境名
#"Python38-pytorch_1.7.0" 是在jupyter中的显示的环境

python -m ipykernel install --user --name python_38-pytorch_1.7.0 --display-name "Python38-pytorch_1.7.0"

http://yann.lecun.com/exdb/mn...

本文含有隐藏内容,请 开通VIP 后查看

网站公告

今日签到

点亮在社区的每一天
去签到