tensorflow1.1及python3安装

19 篇文章 0 订阅
2 篇文章 0 订阅

一 。安装python3.5.3

1.安装tkinter(不需要这个模块的不用安装,import matplotlib.pyplot 需要此模块)

下载ActiveTcl-8.5    

tar -zxvf   ActiveTcl8.5.18.0.298892-Linux-x86_64-threaded.tar.gz 

解压进入文件夹  执行./install.sh  

路径安装在/opt/ActiveTcl-8.5

2.下载Python-3.5.3.tar.gz文件(https://www.python.org/ftp/python/3.5.3/),

tar -xzvf python-3.5.3.tar.gz

cd python-3.5.3

./configure –prefix=/usr/local/python3.5   –with-tcltk-includes=’-I/opt/ActiveTcl-8.5/include’  –with-tcltk-libs=’/opt/ActiveTcl-8.5/lib/libtcl8.5.so /opt/ActiveTcl-8.5/lib/libtk8.5.so’

sudo make && make install

建立软连接,使系统默认的python指向python3.5

##sudo mv /usr/bin/python /usr/bin/python2.6.6.old

sudo ln -s /usr/local/python3.5/bin/python3.5   /usr/bin/python

已经安装完成python的安装或升级的全部操作了,我们再来看一下现在的python的版本:

# python -V

python

虽然现在python已经安装完成,但是使用yum命令会有问题——yum不能正常工作:

这是因为yum默认使用的python版本是2.6.6,到哪是现在的python版本是3.5.3,故会出现上述问题,只需要该一下yum的默认python配置版本就行了:

#vi /usr/bin/yum

将文件头部的#!/usr/bin/python改为

#!/usr/bin/python2.6



测试:执行python

>>> import tkinter
报错:没有_tkinter模块

解决:


本次错误信息为:

libXss.so.1: cannot open shared object file: No such file or directory

解决:sudo yum install libXScrnSaver

再次make,没有libXss.so.1 错误信息

继续对python  进行make install

解决方法参照:http://www.tkdocs.com/tutorial/install.html

#####二.install pip for python3.x

其实这也不难。。下载量个包,执行两个命令搞定。

1.首先安装setuptools

  小伙伴们可以通过官方模块库来下载:https://pypi.python.org/pypi

  这里我就直接用wget到服务器上下载了版本为19.6(小伙伴们可以尝试新的版本奥。。)

复制代码
wget --no-check-certificate  https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26

tar -zxvf setuptools-19.6.tar.gz

cd setuptools-19.6.tar.gz

python3 setup.py build

python3 setup.py install
复制代码

2.然后直接安装pip就搞定了。。

  同样先下载然后在执行命令搞定!!

复制代码
wget --no-check-certificate  https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb

tar -zxvf pip-8.0.2.tar.gz

cd pip-8.0.2

python3 setup.py build

python3 setup.py install
复制代码

安装完成之后我们再来看下python的bin目录下都有什么东西吧

哈哈。。通过以上我们已经给python3安装好了 pip3了。。。(小伙伴们也可以做个软连接,来方便实用奥。。)

(python3.5.3自带pip3 在安装路径/usr/local/python3.5/bin下,直接可以使用,

可以做软链接:sudo ln -s /usr/local/python3.5/bin/pip3 /usr/bin/pip3)

三。

Install TensorFlow

Assuming the prerequisite software is installed on your linux host, take the following steps:

  1. Install TensorFlow by invoking one of the following commands:

       
       
    sudo pip3 install tensorflow # Python 3.n; CPU support (no GPU support) sudo pip3 install tensorflow-gpu # Python 3.n; GPU support



#####(Optional.) If Step 1 failed, install the latest version of TensorFlow by issuing a command of the following format:

 
 
$ sudo pip install --upgrade TF_PYTHON_URL # Python 2.7 $ sudo pip3 install --upgrade TF_PYTHON_URL # Python 3.N

where TF_PYTHON_URL identifies the URL of the TensorFlow Python package. The appropriate value ofTF_PYTHON_URLdepends on the operating system, Python version, and GPU support. Find the appropriate value forTF_PYTHON_URL for your system here. For example, if you are installing TensorFlow for Linux, Python version 3.4, and CPU-only support, issue the following command:

 
 
$ sudo pip3 install --upgrade \ https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.1.0rc2-cp35-cp35m-linux_x86_64.whl
  • 四。测试
  • Run a short TensorFlow program
  • Invoke python from your shell as follows:

       
       
    $ python

    Enter the following short program inside the python interactive shell:

    
        
        
    >>> import tensorflow as tf >>> hello = tf.constant('Hello, TensorFlow!') >>> sess = tf.Session() >>> print(sess.run(hello))

    If the system outputs the following, then you are ready to begin writing TensorFlow programs:

       
       
    Hello, TensorFlow!
  • 五。问题:
  • 1.
    

  • yum install gcc
    wget http://ftp.gnu.org/pub/gnu/glibc/glibc-2.19.tar.xz
    xz -d glibc-2.19.tar.xz
    tar -xvf glibc-2.19.tar.xz
    cd glibc-2.19
    mkdir build
    cd build
    ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin  
    make && make install
    需要等大概10分钟。
    输入strings /lib64/libc.so.6|grep GLIBC发现已经更新 
    GLIBC_2.2.5
    GLIBC_2.2.6
    GLIBC_2.3
    GLIBC_2.3.2
    GLIBC_2.3.3
    GLIBC_2.3.4
    GLIBC_2.4
    GLIBC_2.5
    GLIBC_2.6
    GLIBC_2.7
    GLIBC_2.8
    GLIBC_2.9
    GLIBC_2.10
    GLIBC_2.11
    GLIBC_2.12
    GLIBC_2.13
    GLIBC_2.14
    GLIBC_2.15
    GLIBC_2.16
    GLIBC_2.17

  • ...
    

    GLIBC_PRIVATE

    2.

  • 方法:#strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
    GLIBCXX_3.4
    GLIBCXX_3.4.1
    GLIBCXX_3.4.2
    GLIBCXX_3.4.3
    GLIBCXX_3.4.4
    GLIBCXX_3.4.5
    GLIBCXX_3.4.6
    GLIBCXX_3.4.7
    GLIBCXX_3.4.8
    GLIBCXX_3.4.9
    GLIBCXX_3.4.10
    GLIBCXX_3.4.11
    GLIBCXX_3.4.12
    GLIBCXX_3.4.13
    GLIBCXX_FORCE_NEW
    GLIBCXX_DEBUG_MESSAGE_LENGTH

    没有GLIBCXX_3.4.14版本支持,继续安装(注意:libstdc++6_4.9.2-10_amd64.deb这是64位,libstdc++6_4.9.2-10_i386.deb这个是32位)

    下载新版本,地址:http://ftp.de.debian.org/debian/pool/main/g/gcc-4.7/libstdc++6_4.9.2-10_amd64.deb
    ar -xlibstdc++6_4.9.2-10_amd64.deb&&tar xvf data.tar.gz  

    #cd    usr/lib/x86_64-linux-gnu
    #ll
    lrwxrwxrwx 1 root root     19 Apr 26 15:21 libstdc++.so.6 -> libstdc++.so.6.0.20
    -rw-r–r– 1 root root 991600 Jan  7  2013 libstdc++.so.6.0.20

    # find / -name libstdc++.so.6
    /usr/lib64/libstdc++.so.6
    /root/usr/lib/x86_64-linux-gnu/libstdc++.so.6

    #mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.bak
    #cp libstdc++.so.6.0.20 /usr/lib64/
    #cd /usr/lib64/

    #chmod +x libstdc++.so.6.0.20
    #ll libstdc++.so.6.0.20
    -rwxr-xr-x 1 root root 991600 Apr 26 15:30 libstdc++.so.6.0.20
    #ln -s libstdc++.so.6.0.20 libstdc++.so.6

    #strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX
    GLIBCXX_3.4
    GLIBCXX_3.4.1
    GLIBCXX_3.4.2
    GLIBCXX_3.4.3
    GLIBCXX_3.4.4
    GLIBCXX_3.4.5
    GLIBCXX_3.4.6
    GLIBCXX_3.4.7
    GLIBCXX_3.4.8
    GLIBCXX_3.4.9
    GLIBCXX_3.4.10
    GLIBCXX_3.4.11
    GLIBCXX_3.4.12
    GLIBCXX_3.4.13
    GLIBCXX_3.4.14
    GLIBCXX_3.4.15
    GLIBCXX_3.4.16
    GLIBCXX_3.4.17

    GLIBCXX_DEBUG_MESSAGE_LENGTH

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值