python(四):centos7安装anaconda

配置源

1、国内源
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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
2. 显示源地址 conda config --set show_channel_urls yes
3、删除
conda config --remove channels 镜像链接

 

一、安装

wget https://repo.anaconda.com/archive/Anaconda3-5.3.0-Linux-x86_64.sh
sh Anaconda3-5.3.0-Linux-x86_64.sh
source /root/anaconda3/etc/profile.d/conda.sh
conda create --name PyTorch python=3.7

 二、配置环境

vim /root/.bashrc
export PATH="/root/anaconda3/bin:$PATH"
source   ~/.bashrc

 三、测试python

python
pip -V
[root@10-8-108-101 ~]# python
Python 3.7.0 (default, Jun 28 2018, 13:15:42) 
[GCC 7.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> torch

四、安装pytorch和tensorflow

1、路径

https://download.pytorch.org/whl/torch_stable.html

2、安装

pip install PyHamcrest
conda install pytorch -c pytorch
pip install torchvision

pip install https://download.pytorch.org/whl/cpu/torch-1.0.1-cp37-cp37m-linux_x86_64.whl
pip install --no-deps torchvision

3、安装到虚拟环境

361  conda create --name PyTorch python=3.7
//创建
362 conda activate PyTorch
//激活
363 conda install pytorch -c pytorch
//在虚拟环境安装
364 pip install torchvision 365 python
//退出虚拟环境
366 conda deactivate 367 python
conda info --envs
//查看
# 删除环境 conda remove -n PyTorch --all
# 修改环境名称 conda create --name pytorch-0.4.1 --clone PyTorch
pip install opencv-python
yum install opencv*
//安装python版opencv

 4、安装tensorflow

//创建环境
conda create --name tensorflow_env python=3.7
//激活进入环境
conda activate tensorflow_env
//安装tensorflow
conda install tensorflow
//验证
  1. python
  2. import tensorflow as ts

 五、注意

1、安装tensorflow时候用镜像,安装pytorch需要你懂的

六、conda常用操作

1、查看

conda config --show-sources
conda config --show
conda config --show channels

2、添加

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://anaconda.mirrors.sjtug.sjtu.edu.cn/pkgs/main
conda config --add channels https://anaconda.mirrors.sjtug.sjtu.edu.cn/pkgs/free
conda config --add channels https://anaconda.mirrors.sjtug.sjtu.edu.cn/pkgs/mro
conda config --add channels https://anaconda.mirrors.sjtug.sjtu.edu.cn/pkgs/msys2
conda config --add channels https://anaconda.mirrors.sjtug.sjtu.edu.cn/pkgs/pro
conda config --add channels https://anaconda.mirrors.sjtug.sjtu.edu.cn/pkgs/r

3、删除

$ conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

 七、pip镜像源

1、常用地址

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

2、临时

可以在使用pip的时候,加上参数-i和镜像地址(如
https://pypi.tuna.tsinghua.edu.cn/simple),
例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pandas,这样就会从清华镜像安装pandas库。
3、windows永久

 windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,然后新建文件pip.ini,即 %HOMEPATH%\pip\pip.ini,在pip.ini文件中输入以下内容(以豆瓣镜像为例):

[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host = pypi.douban.com

 



posted @ 2021-03-08 20:55  jasonzhangxianrong  阅读(238)  评论(0编辑  收藏  举报