.conda常用的命令
1)查看安装了哪些包
conda list
2)查看当前存在哪些虚拟环境
conda env list
3)检查更新当前conda
conda update conda
3.Python创建虚拟环境
conda create -n your_env_name python=x.x
anaconda命令创建python版本为x.x,名字为your_env_name的虚拟环境。your_env_name文件可以在Anaconda安装目录envs文件下找到。
4.激活或者切换虚拟环境
打开命令行,输入python --version检查当前 python 版本。
source activate your_env_nam
Windows: activate your_env_name
5.对虚拟环境中安装额外的包
conda install -n your_env_name [package]
6.关闭虚拟环境(即从当前环境退出返回使用PATH环境中的默认python版本)
Linux下:
source deactivate
7.删除虚拟环境
conda remove -n your_env_name --all
8.删除环境钟的某个包
conda remove --name $your_env_name $package_name
9.修改conda,通过以下命令进行添加
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
修改后可以通过以下命令查看:
conda info
下载试试:如果两都能看到下载源,那么就更改成功。
conda install
10.修改pip源
1)Linux系统下:
linux系统下要到用户的文件夹下新建目录.pip,并在目录新建配置文件pip.conf
mkdir ~/.pip
cd ~/.pip
vi pip.conf
编辑内容:
[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn
disable-pip-version-check = true
timeout = 6000
3清除索引缓存
conda clean -i
查看镜像源
conda config --show # 显示当前配置状态
conda config --get channels # 查看当前配置状态
pip临时换源:
复制代码
#清华源
pip3 install markdown -i https://pypi.tuna.tsinghua.edu.cn/simple
阿里源
pip3 install markdown -i https://mirrors.aliyun.com/pypi/simple/
腾讯源
pip3 install markdown -i http://mirrors.cloud.tencent.com/pypi/simple
豆瓣源
pip3 install markdown -i http://pypi.douban.com/simple/
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 config set global.index-url http://mirrors.cloud.tencent.com/pypi/simple
豆瓣源
pip config set global.index-url http://pypi.douban.com/simple/
换回默认源
pip config unset global.index-url https://pypi.org/simple