一、安装python3.6
1、安装tkinter
yum install gcc gcc-c++ zlib zlib-devel openssl openssl-devel libXScrnSaver tkinter tk-devel readline-devel -y
yum install readline-devel -y python 无法退格
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 --enable-shared
(编译成动态库用 --enable-shared参数;编译成静态库用--enable-static参数)
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 如有 直接跳到 步骤三、]
软链接pip3 sudo ln -s /usr/local/python3.6/bin/pip3 /usr/bin/pip3
虽然现在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
三、安装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()
[会出现wasn't compiled to use SSE4.1 SSE4.2 AVX AVX2 FMA警告]
>>> print(sess.run(hello))
If the system outputs the following, then you are ready to begin writing TensorFlow programs:
b'Hello, TensorFlow!'则成功!
华旅网络 |