一、安装python3.6
1、安装tkinter(不需要这个模块的不用安装,import matplotlib.pyplot 需要此模块)
下载ActiveTcl-8.5(或最新版本)
wget http://downloads.activestate.com/ActiveTcl/releases/8.5.18.0/ActiveTcl8.5.18.0.298892-linux-x86_64-threaded.tar.gz
tar -zxvf ActiveTcl8.5.18.0.298892-linux-x86_64-threaded.tar.gz
cd ActiveTcl8.5.18.0.298892-linux-x86_64-threaded
解压进入文件夹 执行./install.sh
路径安装在/opt/ActiveTcl-8.5
2.下载Python-3.6.2.tar.gz文件
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz
tar xvf Python-3.6.2.tgz
cd Python-3.6.2
/*./configure --prefix=/usr/local/python3.6 --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' */
./configure --prefix=/usr/local/python3.6 --enable-shared
[如出错:]yum install gcc gcc-c++ zlib zlib-devel openssl openssl-devel libXScrnSaver tkinter tk-devel -y即可
sudo make && make install [出错]yum install zlib zlib-devel -y
建立软连接,使系统默认的python指向python3.6
##sudo mv /usr/bin/python /usr/bin/python2.7.5.old(centos 自带旧版本)
sudo ln -s /usr/local/python3.6/bin/python3.6 /usr/bin/python
已经安装完成python的安装或升级的全部操作了,我们再来看一下现在的python的版本:
# python -V [如查不到libpython3.6m.so.1.0]则:
执行 cd /etc/ld.so.conf.d
执行 vi python.conf[新建]
/usr/local/python3.6/lib[添加&保存]
执行 /sbin/ldconfig -v
python [查看/usr/local/python3.6/bin 中 是否含有pip3,pip3.6 pip 如有 直接跳到 步骤三、]
虽然现在python已经安装完成,但是使用yum命令会有问题——yum不能正常工作:
这是因为yum默认使用的python版本是2.7.5,到哪是现在的python版本是3.6.2,故会出现上述问题,只需要该一下yum的默认python配置版本就行了:
#vi /usr/bin/yum # vi /usr/libexec/urlgrabber-ext-down
将文件头部的#!/usr/bin/python改为
#!/usr/bin/python2.7
测试:执行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
二、安装pip3
1.首先安装setuptools
通过官方模块库来下载:https://pypi.python.org/pypi
这里直接用wget到服务器上下载了版本为36.3
wget --no-check-certificate https://pypi.python.org/packages/25/56/8911aee89553b72f799f80790ddf1c36aeda125eb5bd0bd3487663856556/setuptools-36.3.0-py2.py3-none-any.whl#md5=72fea26c038d3b61476bc54316cac9a7
tar -zxvf setuptools-36.3.tar.gz
cd setuptools-36.3
python setup.py build
python setup.py install
-----------------------------------------------------------------------------------------
2.然后直接安装pip9.0.1
wget --no-check-certificate https://pypi.python.org/packages/b6/ac/7015eb97dc749283ffdec1c3a88ddb8ae03b8fad0f0e611408f196358da3/pip-9.0.1-py2.py3-none-any.whl#md5=297dbd16ef53bcef0447d245815f5144
tar -zxvf pip-9.0.1.tar.gz
cd pip-9.0.1
python setup.py build
python setup.py install
------------------------------------------------------------------------------------------
软链接pip3 sudo ln -s /usr/local/python3.6/bin/pip3 /usr/bin/pip3
三、安装tensorflow
Install TensorFlow by invoking one of the following commands:[命令如下:]
sudo pip3 install tensorflow # Python 3.n; CPU support (no GPU support)不支持GPU
sudo pip3 install tensorflow-gpu # Python 3.n; GPU support支持GPU
$ sudo pip3 install --upgrade https://pypi.python.org/packages/7c/9f/57e1404fc9345759e4a732c4ab48ab4dd78fd1e60ee1270442b8850fa75f/tensorflow-1.3.0-cp36-cp36m-manylinux1_x86_64.whl#md5=7a450d33386d17ab85e9e3656551c320 [不支持GPU]
[ImportError: cannot import name 'HTTPSHandler']yum install openssl openssl-devel -y即可
四、测试
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
华旅网络 |