anaconda环境---ubuntu下重装
anaconda环境---ubuntu下重装
@wp20190312
为何重装? 配置一个环境,意外发现conda命令不好用了,提示“找不到conda模块”,整个conda虚拟环境中的工程项目无法使用,网上有说主要是python路径的指向调用出现了问题。经过多番尝试仍然未解决问题,所以还是重装一下吧,简单bao力。
原来使用的是anaconda2,这次改用anaconda3。
(1)卸载原来的anaconda2:rm -rf /home/wp/anaconda2
(2)安装新的anaconda3
在网址 https://www.cnblogs.com/gaofighting/p/8799169.html 中下载anaconda3
wp@wp-MS-7519:~/Anaconda3$ sudo sh Anaconda3-2018.12-Linux-x86_64.sh #安装完后带锁
sh Anaconda3-2018.12-Linux-x86_64.sh #安装完后不带锁
=======================安装过程部分展示================================
一直enter到选择yes?
Anaconda3 will now be installed into this location:
/home/wp/anaconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/home/wp/anaconda3] >>>
PREFIX=/home/wp/anaconda3
# 安装根据机器性能,通常需要持续几分钟。
Do you wish the installer to initialize Anaconda3
in your /home/wp/.bashrc ? [yes|no]
[no] >>>
You may wish to edit your /home/wp/.bashrc to setup Anaconda3:
source /home/wp/anaconda3/etc/profile.d/conda.sh
Thank you for installing Anaconda3!
====================================================================
To install Visual Studio Code, you will need:
- Administrator Privileges
- Internet connectivity
Visual Studio Code License: https://code.visualstudio.com/license
Do you wish to proceed with the installation of Microsoft VSCode? [yes|no]
>>> yes
Proceeding with installation of Microsoft VSCode
VSCode is already installed!
到此Anaconda3安装成功。 重启终端,即可使用Anaconda3
假如,Anaconda3未安装成功,可以执行: rm -rf ~/anaconda3
,找到Anaconda3的安装路径,卸载后重新安装即可。
===============================================================
(3)在终端,查看当前电脑的python版本:
wp@wp-MS-7519:~/anaconda3$ python
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
wp@wp-MS-7519:~/anaconda3$ python3
Python 3.6.5 (default, Apr 1 2018, 05:46:30)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
我们可以看到,若在终端输入 python,仍然会显示Ubuntu自带的python版本。
(4)所以如果想用anaconda,则需要修改终端的默认python为anaconda,执行:
wp@wp-MS-7519:~/anaconda3$ gedit ~/.bashrc
在文件后面添加:export PATH="/home/wp/anaconda3/bin:$PATH" #并保存
wp@wp-MS-7519:~/anaconda3$ source ~/.bashrc #使用修改的路径生效
【export PATH=/home/wp/anaconda2/bin:$PATH
gedit ~/.bashrc
source ~/.bashrc】
(5)再次,查看当前电脑的python版本:
wp@wp-MS-7519:~/anaconda3$ python -V
Python 3.7.1 #anaconda3 安装的python版本
wp@wp-MS-7519:~/anaconda3$ python
Python 3.7.1 (default, Dec 14 2018, 19:28:38)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
wp@wp-MS-7519:~/anaconda3$ python2
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
(6)根据工作要求,增加虚拟环境。
6.1查找可用版本:conda search "^python$"
wp@wp-MS-7519:~/anaconda3$ conda search "^python$"
Loading channels: done
# Name Version Build Channel
python 1.0.1 0 anaconda/cloud/conda-forge
python 1.0.1 0 anaconda/pkgs/free
........
python 2.7.3 2 anaconda/pkgs/free
python 2.7.3 3 anaconda/pkgs/free
python 2.7.3 4 anaconda/pkgs/free
python 2.7.3 5 anaconda/pkgs/free
......................
python 2.7.15 0 anaconda/cloud/conda-forge
python 2.7.15 h1571d57_0 anaconda/pkgs/main
python 2.7.15 h33da82c_1 anaconda/cloud/conda-forge
python 2.7.15 h33da82c_3 anaconda/cloud/conda-forge
python 2.7.15 h33da82c_4 anaconda/cloud/conda-forge
...
python 2.7.15 h9bab390_2 anaconda/pkgs/main
python 2.7.15 h9bab390_4 anaconda/pkgs/main
python 2.7.15 h9bab390_6 anaconda/pkgs/main
python 2.7.15 h9fef7bc_0 anaconda/cloud/conda-forge
................................
python 3.5.0 0 anaconda/pkgs/free
python 3.5.0 1 anaconda/pkgs/free
python 3.5.1 0 anaconda/cloud/conda-forge
python 3.5.1 0 anaconda/pkgs/free
python 3.5.1 1 anaconda/cloud/conda-forge
python 3.5.1 5 anaconda/pkgs/free
python 3.5.2 0 anaconda/cloud/conda-forge
python 3.5.2 0 anaconda/pkgs/free
python 3.5.2 1 anaconda/cloud/conda-forge
...
python 3.5.5 hc3d631a_0 anaconda/pkgs/main
python 3.5.5 hc3d631a_1 anaconda/pkgs/main
python 3.5.5 hc3d631a_3 anaconda/pkgs/main
python 3.5.5 hc3d631a_4 anaconda/pkgs/main
python 3.5.6 hc3d631a_0 anaconda/pkgs/main
python 3.6.0a3 0 anaconda/cloud/conda-forge
............................
python 3.6.7 hd21baee_1002 anaconda/cloud/conda-forge
python 3.6.8 h0371630_0 anaconda/pkgs/main
python 3.7.0 h5001a0f_0 anaconda/cloud/conda-forge
python 3.7.0 h5001a0f_1 anaconda/cloud/conda-forge
python 3.7.0 h5001a0f_4 anaconda/cloud/conda-forge
python 3.7.0 h5001a0f_6 anaconda/cloud/conda-forge
python 3.7.0 h6e4f718_3 anaconda/pkgs/main
...
python 3.7.1 h0371630_7 anaconda/pkgs/main
python 3.7.1 h381d211_1002 anaconda/cloud/conda-forge
python 3.7.1 h5001a0f_0 anaconda/cloud/conda-forge
python 3.7.1 hd21baee_1000 anaconda/cloud/conda-forge
python 3.7.1 hd21baee_1001 anaconda/cloud/conda-forge
python 3.7.2 h0371630_0 anaconda/pkgs/main
6.2下载的TensorFlow对应的Python版本一定要和conda create -n tensorflow python=x.x的版本一样才行。
考虑,环境没破坏之前,FaceNet使用的环境:Ubuntu 18.04 + Tensorflow 1.5.0 + Python 2.7 + OpenCV 3.2.0,
A1,这里,装一个Python 2.7,配一个Tensorflow 1.5.0 环境。
wp@wp-MS-7519:~/anaconda3$ conda create -n test_py2 python=2
wp@wp-MS-7519:~/anaconda3$ source activate test_py2
wp@wp-MS-7519:~/anaconda3$ python #查看是python2.7.15
wp@wp-MS-7519:~/anaconda3$ pip install tensorflow
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Looking in indexes: http://pypi.douban.com/simple
Collecting tensorflow
Downloading http://pypi.doubanio.com/packages/d2/ea/ab2c8c0e81bd051cc1180b104c75a865ab0fc66c89be992c4b20bbf6d624/tensorflow-1.13.1-cp27-cp27mu-manylinux1_x86_64.whl (92.5MB)
B1,安装完成后,python ,import tensorflow as tf,报错
>>> import tensorflow as tf
2019-03-11 16:39:04.749263: F tensorflow/core/platform/cpu_feature_guard.cc:37] The TensorFlow library was compiled to use SSE4.2 instructions, but these aren't available on your machine.
已放弃 (核心已转储)
解决办法:安装bazel,编译tensorflow。这个问题的原因是CPU支持更快的运算,安装的Tensorflow中缺少对应的模块,需要编译安装。当我们使用GPU的情况下,并不需要用到CPU,所以这些warning可以忽略。 安装bazel 太麻烦了,换思路解决“安装tf”。
C1,卸载tensorflow:(test_py2) wp@wp-MS-7519:~/anaconda3$ pip uninstall tensorflow
D1,重新安装tensorflow:sudo pip install --ignore-installed --upgrade https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/cpu/tensorflow-1.5.0-cp27-none-linux_x86_64.whl
这里说明一下: 这一步安装之后,python2下面import tensorflow as tf 还是报错,但是在python3下面import tensorflow as tf 不报错。所以,换思路。
A2,换思路,装一个Python 3.5,配一个Tensorflow 1.5.0 环境。【刚开始装的是Python 3.6和Tensorflow 1.5.0 最后不好用,经过折腾换Python 3.5好用。】
wp@wp-MS-7519:~/anaconda3$ conda create -n test_py3 python=3.6
wp@wp-MS-7519:~/anaconda3$ source activate test_py3
(test_py3) wp@wp-MS-7519:~/anaconda3$ cd test_py3
(test_py3) wp@wp-MS-7519:~/anaconda3/test_py3$ cd tf
(test_py3) wp@wp-MS-7519:~/anaconda3/test_py3/tf$ python
Python 3.6.7 | packaged by conda-forge | (default, Feb 28 2019, 09:07:38)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
安装tf:sudo pip install --ignore-installed --upgrade https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/cpu/tensorflow-1.5.0rc0-cp36-cp36m-linux_x86_64.whl
安装tf报错:tensorflow-1.5.0rc0-cp36-cp36m-linux_x86_64.whl is not a supported wheel on this platform.
退出虚拟环境,并卸载python3.6,重装python3.5
(test_py3) wp@wp-MS-7519:~/anaconda3/test_py3/tf$ source deactivate (conda deactivate) #退出虚拟环境
wp@wp-MS-7519:~/anaconda3/test_py3/tf$ conda remove --name test_py3 --all #卸载python3.6
wp@wp-MS-7519:~/anaconda3/test_py3/tf$ conda create -n test_py3 python=3.5 #重装python3.5
(test_py3) wp@wp-MS-7519:~/anaconda3/test_py3/tf$ conda activate test_py3
(test_py3) wp@wp-MS-7519:~/anaconda3/test_py3/tf$ pip install --ignore-installed --upgrade tensorflow-1.5.0-cp35-cp35m-linux_x86_64.whl
【安装下载镜像网址 https://mirrors.tuna.tsinghua.edu.cn/tensorflow/linux/cpu/】
(test_py3) wp@wp-MS-7519:~/anaconda3/test_py3/tf$ python
Python 3.5.5 | packaged by conda-forge | (default, Jul 23 2018, 23:45:43)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__
'1.5.0'
>>>
提示,这里需要 py 和 tf 版本相匹配,所以可能会出现反复的:
(1)安装 conda create -n test_py3 python=3.5 与卸载 conda remove --name test_py3 --all ,
(2)安装 pip install --ignore-installed --upgrade tf_setup_name 与卸载 pip uninstall tensorflow 。
【
总结说明:
安装可用环境:conda create --name my_env python=3
删除环境变量:conda remove --name my_env --all
激活新环境:source activate my_env
停用环境:source deactivate
安装可用环境python3.5版本:conda create -n my_env35 python=3.5
删除可用环境python3.5版本:conda remove --name my_env35 --all
激活新环境:source activate my_env
停用:source deactivate
更新版本:conda update python=3.5.2
查看所有环境:conda info --envs
给环境安装其他软件包:conda install --name my_env35 numpy
更新 anaconda:conda update conda
卸载Anaconda:conda install anaconda-clean --yes
rm -rf ~/anaconda3
vim ~/.bashrc
更换仓库镜像
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
】
anaconda环境---ubuntu下重装的更多相关文章
- 吴恩达深度学习第4课第3周编程作业 + PIL + Python3 + Anaconda环境 + Ubuntu + 导入PIL报错的解决
问题描述: 做吴恩达深度学习第4课第3周编程作业时导入PIL包报错. 我的环境: 已经安装了Tensorflow GPU 版本 Python3 Anaconda 解决办法: 安装pillow模块,而不 ...
- ubuntu 下重装mysql若干问题
最近由于种种原因需要重装mysql.打开终端开始卸载 sudo apt-get remove mysql-comm sudo apt-get auto remove 重新开始安装mysql sudo ...
- Ubuntu下Java开发环境搭建(eclipse)
最近把工作环境转移到了Ubuntu Kylin下,发现在这下面Java环境还是很方便的.然而也经历了一些摸索的过程,故作文以记之. 一/开发前准备 安装系统/配置软件源,这部分内容没什么需要注意的.O ...
- ubuntu 下python环境的切换使用
如何在Anaconda的python和系统自带的python之间切换 一般ubuntu下有三种python环境,1. 系统自带python2,3;在/usr/bin路径下:2. anaconda下安装 ...
- Ubuntu下常用强化学习实验环境搭建(MuJoCo, OpenAI Gym, rllab, DeepMind Lab, TORCS, PySC2)
http://lib.csdn.net/article/aimachinelearning/68113 原文地址:http://blog.csdn.net/jinzhuojun/article/det ...
- ubuntu下基于Anaconda使用Tensorflow
为了在ubuntu下利用Anaconda使用tensorflow,但在利用conda安装tensorflow,不能在终端,spyder和notebook中直接使用,需要我们进行一定的配置. 1.安装A ...
- win10+anaconda环境下pyqt5+qt tools+eric6.18安装及汉化过程
最近需要用python编写一个小程序的界面,选择了pyqt5+eric6的配套组合,安装过程中遇到一些坑,特此记录.参考书籍是电子工业出版社的<PyQt5快速开发与实战>. 因为我使用an ...
- 记ubuntu下安装Anaconda
晚上尝试在ubuntu 16.04版本下安装python的Anaconda3发行版. 从清华源下载的Anaconda3-Linux 64位版本安装包,然后顺利的下一步,下一步.....一切顺利!结果到 ...
- Ubuntu+anaconda环境里安装opencv
在Ubuntu的Anaconda环境下安装OpenCV比较方便,直接在终端中输入以下命令: conda install --channel https://conda.anaconda.org/men ...
随机推荐
- IDEA配置SpringBoot应用的profile启动参数
参考博客:https://blog.csdn.net/li396864285/article/details/83576829 如图为, 配置多台eureka的启动参数, 分别为: --spring. ...
- window环境下zookeeper的安装(自用---仅供参考)
转自: https://www.cnblogs.com/ysw-go/p/11396343.html 第一部分:单机模式 1)下载地址:http://www.pirbot.com/mirrors/ap ...
- 最新 易车java校招面经 (含整理过的面试题大全)
从6月到10月,经过4个月努力和坚持,自己有幸拿到了网易雷火.京东.去哪儿.易车等10家互联网公司的校招Offer,因为某些自身原因最终选择了易车.6.7月主要是做系统复习.项目复盘.LeetCode ...
- 能力不足的C++开发会欺辱能力不足C#开发
能力不足的C++开发会欺辱能力不足C#开发 我被C++开发欺辱的岁月 前言 人被压迫了,为什么不斗争?——鲁迅 作为一个C#开发者,我经历了,也见证了很多同行饱受C++开发的歧视和欺辱. 而且,这 ...
- 学习笔记:CentOS7学习之二十四:expect-正则表达式-sed-cut的使用
目录 学习笔记:CentOS7学习之二十四:expect-正则表达式-sed-cut的使用 24.1 expect实现无交互登录 24.1.1 安装和使用expect 24.2 正则表达式的使用 24 ...
- GFS(Google File System,谷歌文件系统)----(1)读写一致性
GFS副本控制协议--中心化副本控制协议 对于副本集的更新操作有一个中心节点来协调管理,将分布式的并发操作转化为单点的并发操作,从而保证副本集内各节点的一致性.在GFS中,中心节点称之为Primary ...
- EasyUI datagrid 动态加载表头和数据
首先返回到页面的需要是JSON数据: 第一步: 遍历表头,插入到array中 for (var i = 0; i < jsonObj.title.length; i++) { //把返回的数据封 ...
- c# bitmap的拷贝及一个图像工具类
using (Bitmap bmp = new Bitmap(scanImgPath)) { Bitmap bitmap = new Bitmap(bmp.Width, bmp.Height, Pix ...
- Java:关于子类继承父类接口时,由于权限没有设定的更广,出错的一个小tip
今天在写笔记的时候,写的地方出现了小叉叉错号. 发现问题: 这里出错了!原因是因为在子类覆写父类的方法的时候,权限不能开的比父类更低! 加了public后,纠错成功. 由于接口类型下的方法默认都是pu ...
- User space(用户空间) 与 Kernel space(内核空间)
出处: User space 与 Kernel space (整理)用户空间_内核空间以及内存映射 学习 Linux 时,经常可以看到两个词:User space(用户空间)和 Kernel spac ...