1. Install Development Kit
#yum groupinstall -y "Development tools"
Other necessary package:
#yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel tcl tcl-devel tk tk-devel
2. Install Python-2.7.16
#wget https://www.python.org/ftp/python/2.7.16/Python-2.7.16.tgz
#tar -zxf Python-2.7.16.tgz
#cd Python-2.7.16
#./configure --enable-unicode=ucs2 --enable-unicode=ucs4 --with-zlib --with-ssl
#make && make install
--enable-unicode=ucs2 --enable-unicode=ucs4
After the installation is to tensorflow.
Python2.7.16 installed by default /usr/local/bin
, the system comes in /usr/bin
next.
Removal system default version:
#mv /usr/bin/python /usr/bin/python.old
If you have python-config
software links, delete:
#rm -f /usr/bin/python-config
Create a soft link to the new version to update the system default version:
#ln -s /usr/local/bin/python /usr/bin/python
#ln -s /usr/local/bin/python-config /usr/bin/python-config
#ln -s /usr/local/include/python2.7 /usr/include/python2.7
After using the new version of Python, yum is not available, can be repaired as follows:
#vi /usr/bin/yum
The first line was changed #!/usr/bin/python2.6
.
In this way, after the upgrade yum, yum will lead can not be used, can be copied from the python2.7 python2.6 to run through the modules used in the yum:
#cp -r /usr/lib/python2.6/site-packages/yum /usr/local/lib/python2.7/site-packages/
#cp -r /usr/lib64/python2.6/site-packages/rpm /usr/local/lib/python2.7/site-packages/
#cp -r /usr/lib/python2.6/site-packages/urlgrabber /usr/local/lib/python2.7/site-packages/
#cp -r /usr/lib64/python2.6/site-packages/pycurl.so /usr/local/lib/python2.7/site-packages/
#cp -r /usr/lib/python2.6/site-packages/rpmUtils /usr/local/lib/python2.7/site-packages/
#cp -r /usr/lib64/python2.6/site-packages/curl /usr/local/lib/python2.7/site-packages/
#cp -p /usr/lib64/python2.6/site-packages/pycurl.so /usr/local/lib/python2.7/site-packages/
#cp -p /usr/lib64/python2.6/site-packages/_sqlitecache.so /usr/local/lib/python2.7/site-packages/
#cp -p /usr/lib64/python2.6/site-packages/sqlitecachec.py /usr/local/lib/python2.7/site-packages/
#cp -p /usr/lib64/python2.6/site-packages/sqlitecachec.pyc /usr/local/lib/python2.7/site-packages/
#cp -p /usr/lib64/python2.6/site-packages/sqlitecachec.pyo /usr/local/lib/python2.7/site-packages/
3. Install pip, virtualenv
Install setuptools:
#wget https://bootstrap.pypa.io/ez_setup.py
#python ez_setup.py
Then easy_install
the command is attached to /usr/local/bin
the lower, use it to install pip
.
#easy_install pip
Or this installation pip
:
#wget https://bootstrap.pypa.io/get-pip.py
#python get-pip.py
#pip -V # 查看版本
#pip freeze # 查看当前安装的模块及版本
#pip freeze > requirements.txt # 把当前环境中所有包及各自的版本的简单列表输出到文件
#pip install -r requirements.txt # 然后可以重建相同版本的相同包的环境,这可以确保安装、部署和开发者之间的一致性
Installation distribute
package:
#pip install distribute
Installation virtualenv
:
#pip install virtualenv
#virtualenv --version
virtualenv
Simple to use:
#mkdir test
#cd test
#virtualenv test # 建立一个虚拟环境
#virtualenv -p /usr/bin/python2.7 test # 可以指定python解释器
#source test/bin/activate # 激活虚拟环境
#deactivate # 停用虚拟环境
Installation virtualenvwrapper
, first make sure that virtualenv
is installed:
#pip install virtualenvwrapper
virtualenvwrapper
Simple to use:
$cd
$mkdir VirtualEnvs # 创建虚拟环境管理目录
$find / -name virtualenvwrapper.sh # 找到virtualenvwrapper.sh的路径,如果不知道在哪,用这个来查找
$export WORKON_HOME=~/VirtualEnvs # 如果创建前要将环境保存到VirtualEnvs中,则要先设置环境变量WORKON_HOME,再搭建环境
$source /usr/local/bin/virtualenvwrapper.sh # 运行virtualenvwrapper.sh
$mkvirtualenv test1 # 创建一个虚拟环境
$mkvirtualenv test1 --python=python2.7 # 可以选择一个python解释器
$workon test1 # 虚拟环境上工作
$deactivate # 停止虚拟环境
$rmvirtualenv test1 # 删除
$lsvirtualenv # 列出所有环境
$cdvirtualenv # 切换到当前环境的目录
$cdsitepackages # 切换到当前环境的site-packages目录
$lssitepackages # 列出site-packages目录的内容
4. Install Python library
$export WORKON_HOME=~/VirtualEnvs
$source /usr/local/bin/virtualenvwrapper.sh
$mkvirtualenv Test
$workon Test
$pip install numpy
$pip install pandas
$pip install matplotlib
$pip install scipy
$pip install sklearn
$pip install jieba
$pip install hmmlearn
$pip install gensim
$pip install tensorflow
$pip install tensorlayer
$pip install torch
$pip install torchvision
$pip install moviepy
$pip install IPython
$pip install visdom
$pip install requests
$pip install beautifulsoup4
$pip install lxml # Beautiful Soup支持Python标准库中的HTML解析器,还支持一些第三方的解析器,如不安装第三方,则用Python默认的解析器。lxml解析器更加强大,速度更快,推荐安装
import tensorflow
When the error: /lib64/libc.so.6: version 'GLIBC_2.16' not found
so you want to upgrade GLIBC.
#cat /etc/redhat-release
#strings /lib64/libc.so.6 | grep GLIBC_
Richard highest version of the CentOS 6.10 GLIBC is 2.12.
(The actual upgrade, version 2.16 failure, so a direct upgrade to 2.18)
#wget http://ftp.gnu.org/gnu/glibc/glibc-2.18.tar.gz
#tar -zxf glibc-2.18.tar.gz
#mkdir glibc-build-2.18
#cd glibc-build-2.18
#../glibc-2.18/configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
#make
#make install
And then check the version:
#strings /lib64/libc.so.6 | grep GLIBC_
We can see the highest version 2.18.
#ls -al /lib64/libc.so.6
Link version is 2.18.
If this process there is an error: /usr/lib64/libstdc++.so.6: version 'CXXABI_1.3.7' not found
, you will have to upgrade gcc.
#strings /usr/lib64/libstdc++.so.6 | grep "CXXABI"
We found the highest version of 1.3.3. Upgrade to gcc 4.8:
#curl -Lks http://www.hop5.in/yum/el6/hop5.repo > /etc/yum.repos.d/hop5.repo
#yum install gcc gcc-g++ -y
#strings /usr/lib64/libstdc++.so.6 | grep "CXXABI"
The highest version displayed is 1.3.7.