Ubuntu16.04+Anaconda安装+换源+环境创建+tensorflow安装

abclhq00 2018-09-09

一、Anaconda,下载

Anaconda 是一个用于科学计算的 Python 发行版,支持 Linux, Mac, Windows, 包含了众多流行的科学计算、数据分析的 Python 包。
1
2

Anaconda 安装包可以到 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 下载。

ps:也可以去官网下载 https://www.anaconda.com/download/

Ubuntu16.04+Anaconda安装+换源+环境创建+tensorflow安装

Ubuntu16.04+Anaconda安装+换源+环境创建+tensorflow安装

ps:本次使用的是Anaconda3-5.0.0-Linux-x86_64.sh

二、Anaconda,安装

进入文件目录:

bash ./Anaconda3-5.0.0-Linux-x86_64.sh
1

回车

Ubuntu16.04+Anaconda安装+换源+环境创建+tensorflow安装

.

.

.

全程 yes +回车 ,默认安装在home目录下
1
2

三、Anaconda,环境变量

1.检查环境变量,没有则添加

查看命令

sudo gedit ~/.bashrc
1

Ubuntu16.04+Anaconda安装+换源+环境创建+tensorflow安装

检查末尾是否已经添加如下变量,没有则添加

export PATH="/home/用户名/anaconda3/bin:$PATH"
1

Ubuntu16.04+Anaconda安装+换源+环境创建+tensorflow安装

需要重启系统,不然找不到命令

2.打开控制台 ,更换清华源(墙太高)

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
1
2
3

3.创建一个名flappbird 的环境

conda create -n flappbird python=3.6
1

创建成功

Ubuntu16.04+Anaconda安装+换源+环境创建+tensorflow安装

激活环境

source activate flappbird
1

四、tensorflow安装

给 flappbird 环境安装tensorflow

conda install -n flappbird -c https://conda.anaconda.org/jjhelmus tensorflow
1

Ubuntu16.04+Anaconda安装+换源+环境创建+tensorflow安装

五、遇到的错误+解决办法

1.如果换源之后任然无法创建环境,并且报网络连接的错误:

报错如下:

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.continuum.io/pkgs/main/linux-64/repodata.json.bz2>
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
ConnectionError(MaxRetryError("HTTPSConnectionPool(host='repo.continuum.io', port=443): Max retries exceeded with url: /pkgs/main/linux-64/repodata.json.bz2 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fd5d462df28>: Failed to establish a new connection: [Errno 101] Network is unreachable',))",),)
1
2
3
4
5
6
7

解决办法:

打开源文件

vim ~/.condarc
1

删除defaults行

Ubuntu16.04+Anaconda安装+换源+环境创建+tensorflow安装

2.如果安装文件夹出现一把小锁,运行命令报错

报错如下

Traceback (most recent call last):
 File "/home/joahluo/Anaconda/lib/python3.6/site-packages/conda/exceptions.py", line 640, in conda_exception_handler
 return_value = func(*args, **kwargs)
 File "/home/joahluo/Anaconda/lib/python3.6/site-packages/conda/cli/main.py", line 140, in _main
 exit_code = args.func(args, p)
 File "/home/joahluo/Anaconda/lib/python3.6/site-packages/conda/cli/main_create.py", line 68, in execute
 install(args, parser, 'create')
 File "/home/joahluo/Anaconda/lib/python3.6/site-packages/conda/cli/install.py", line 231, in install
 unknown=index_args['unknown'], prefix=prefix)
 File "/home/joahluo/Anaconda/lib/python3.6/site-packages/conda/core/index.py", line 101, in get_index
 index = fetch_index(channel_priority_map, use_cache=use_cache)
 File "/home/joahluo/Anaconda/lib/python3.6/site-packages/conda/core/index.py", line 120, in fetch_index
 repodatas = collect_all_repodata(use_cache, tasks)
 File "/home/joahluo/Anaconda/lib/python3.6/site-packages/conda/core/repodata.py", line 75, in collect_all_repodata
 repodatas = _collect_repodatas_serial(use_cache, tasks)
 File "/home/joahluo/Anaconda/lib/python3.6/site-packages/conda/core/repodata.py", line 485, in _collect_repodatas_serial
 for url, schan, pri in tasks]
 File "/home/joahluo/Anaconda/lib/python3.6/site-packages/conda/core/repodata.py", line 485, in <listcomp>
 for url, schan, pri in tasks]
 File "/home/joahluo/Anaconda/lib/python3.6/site-packages/conda/core/repodata.py", line 115, in func
 res = f(*args, **kwargs)
 File "/home/joahluo/Anaconda/lib/python3.6/site-packages/conda/core/repodata.py", line 473, in fetch_repodata
 with open(cache_path, 'w') as fo:
 PermissionError: [Errno 13] Permission denied: '/home/joahluo/Anaconda/pkgs/cache/09e2740c.json'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

解决办法:

运行如下命令,赋予权限

sudo chmod -R 777 Anaconda
1

ps:其中Anaconda是我的安装的文件夹名字

相关推荐