0
点赞
收藏
分享

微信扫一扫

linux中的conda使用

624c95384278 2022-01-21 阅读 70

conda

安装

# 使用以下命令下载conda
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh
# 注:若命令不存在,执行 yum install wget -y 安装即可

bash Miniconda3-latest-Linux-x86_64.sh 
# 安装的过程中,一路yes或者回车即可
# 添加环境变量
source /root/.bashrc

配置 aconda 仓库镜像源

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

配置相关环境

# 下载安装TensorFlow,OpenCV,jupyter
conda install -y tensorflow opencv jupyter

相关命令

conda update -n base conda        #update最新版本的conda
conda create -n xxxx python=3.5   #创建python3.5的xxxx虚拟环境
conda activate xxxx               #开启xxxx环境
conda deactivate                  #关闭环境
conda env list                    #显示所有的虚拟环境
conda info --envs                 #显示所有的虚拟环境
conda list         #查看已经安装的文件包
conda list  -n xxx       #指定查看xxx虚拟环境下安装的package
conda update xxx   #更新xxx文件包
conda uninstall xxx   #卸载xxx文件包
conda clean -p      //删除没有用的包
conda clean -t      //删除tar包
conda clean -y --all //删除所有的安装包及cache

# 彻底删除旧环境
conda remove --name oldname --all      

python克隆环境

# 克隆oldname环境为newname环境
conda create --name newname --clone oldname 
#输出结果会提供一个下载地址,使用下面命令就可指定安装1.8.0版本tensorflow
conda install --channel https://conda.anaconda.org/anaconda tensorflow=1.8.0 

配置讯数据源

#显示目前pip的数据源有哪些
pip config list
pip config list --[user|global] # 列出用户|全局的设置
pip config get global.index-url # 得到这key对应的value 如:https://mirrors.aliyun.com/pypi/simple/

# 添加
pip config set key value
#添加数据源:例如, 添加USTC中科大的源:
pip config set global.index-url https://mirrors.ustc.edu.cn/pypi/web/simple
pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/
#添加全局使用该数据源
pip config set global.trusted-host https://mirrors.ustc.edu.cn/pypi/web/simple

# 删除
pip config unset key
# 例如
conda config --remove channels  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

#搜索
pip search flask  #搜素flask安装包

# 升级pip
pip install pip -U

国内镜像源

阿里云                    http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

pip list #列出当前缓存的包
pip purge #清除缓存
pip remove #删除对应的缓存
pip help #帮助
pip install xxx #安装xxx包
pip uninstall xxx #删除xxx包
pip show xxx #展示指定的已安装的xxx包
pip check xxx #检查xxx包的依赖是否合适

linux下载pytorch

conda install pytorch==1.9.0 torchvision==0.10.0 torchaudio==0.9.0 cudatoolkit=10.2 -c pytorch

举报

相关推荐

0 条评论