ubuntu16.04下安装tensorflow(二)

本文详细介绍在Ubuntu 16.04环境下安装TensorFlow的过程,包括安装pip、解决安装过程中遇到的问题及验证安装是否成功的方法。此外还介绍了Komodo Edit IDE的安装步骤,以及如何在该环境中安装和配置必要的Python库。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一.tensorflow的环境
ubuntu16.04的环境、系统自带pythond的环境
1、进入窗口的模式:
输入python的命令,发现已经存在python。
2、输入以下命令安装pip

sudo apt-get install python-pip python-dev


3、安装pip

sudo pip install --upgrade https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=cpu-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.2.0rc1-cp27-none-linux_x86_64.whl

此处的链接为:https://github.com/tensorflow/tensorflow寻找自己需要的软件包

会出现如下的错误:

4、此处需要更新pip

sulei@sulei:~$ pip install --upgrade pip


5、继续执行上面的命令

 sudo pip install --upgrade https://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=cpu-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-1.2.0rc1-cp27-none-linux_x86_64.whl

结果:

安装成功:

6、测试
进入python

>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2017-06-07 22:31:06.638258: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-06-07 22:31:06.638339: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-06-07 22:31:06.638376: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
>>> print sess.run(hello)
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print sess.run(a+b)
42

7、IDEA的安装
好用的IDE有很多,本文介绍的是Komodo IDE的免费版Komodo Edit。在Linux下打开它的官网(点击链接http://komodoide.com/download/edit-linux64/#
下载解压后,进入解压目录;
在终端的命令下进入目录并进行

sulei@sulei:~/文档/Komodo$ ./install.sh 
nter directory in which to install Komodo. Leave blank and
press 'Enter' to use the default [~/Komodo-Edit-10].
Install directory: 


==============================================================================
Komodo Edit 10 has been successfully installed to:
    /home/sulei/Komodo-Edit-10

You might want to add 'komodo' to your PATH by adding the 
install dir to you PATH. Bash users can add the following
to their ~/.bashrc file:

    export PATH="/home/sulei/Komodo-Edit-10/bin:$PATH"

Or you could create a symbolic link to 'komodo', e.g.:

    ln -s "/home/sulei/Komodo-Edit-10/bin/komodo" /usr/local/bin/komodo

Documentation is available in Komodo or on the web here:
    http://docs.activestate.com/komodo

Please send us any feedback you have through one of the
channels below:
    komodo-feedback@activestate.com
    irc://irc.mozilla.org/komodo
    https://github.com/Komodo/KomodoEdit/issues

Thank you for using Komodo.
==============================================================================

根据路径找到这个文件,并打开

进行设置:

补充:
1、安装virtualenv

sulei@sulei:~$ sudo pip install virtualenv

这里写图片描述
2、安装numpy和matplotlib

sulei@sulei:~$ sudo pip install numpy
sulei@sulei:~$ sudo pip install matplotlib

这里写图片描述
此处出现matplotlib的安装错误:
这里写图片描述
如果matplotlib 装不上需要先安装其依赖的包libpng和freetype
安装libpng:

sudo apt-get install libpng-dev

这里写图片描述
安装freetype:

cd ~/Downloads
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.10.tar.gz
tar zxvf freetype-2.4.10.tar.gz
cd freetype-2.4.10/
./congfigure
make
sudo make install



安装matplotlib

sudo pip install matplotlib


安装成功
3、安装opencv
下载opencv的发行版源码:

https://github.com/opencv/opencv/releases/tag/2.4.13.2
tar -vxzf opencv-2.4.13.2.tar.gz
安装编译源码的依赖:
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

这里写图片描述
进入源码目录并配置:

cd opencv-2.4.13.2/
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

编译安装:

make
sudo make install

进入Python Console,在Python Console中输入:

import cv2

这里写图片描述

如果没有报错,则说明opencv安装好了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值