sh 在CentOS 7上安装本地Python 2.7.10

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 在CentOS 7上安装本地Python 2.7.10相关的知识,希望对你有一定的参考价值。

TMP_PATH=~/tmp_install_python
#Install python3-tk and tk-dev
sudo aptitude install python3-tk
sudo aptitude install tk-dev

# Versions section
PYTHON_MAJOR=2.7
PYTHON_VERSION=$PYTHON_MAJOR.10

mkdir $TMP_PATH && cd $TMP_PATH

# Update yum and libraries
yum -y update
yum groupinstall -y development
yum install python-tools.x86_64
yum install tk tk-devel tcl tcl-devel
yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel
yum install xclock

# Download and extract Python and Setuptools
wget --no-check-certificate https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz
wget --no-check-certificate https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
wget --no-check-certificate https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py 
tar -zxvf Python-$PYTHON_VERSION.tgz

# Compile Python
cd $TMP_PATH/Python-$PYTHON_VERSION
./configure --prefix=/usr/local
make && make altinstall
export PATH="/usr/local/bin:$PATH"

# Install Setuptools and PIP
cd $TMP_PATH
/usr/local/bin/python$PYTHON_MAJOR ez_setup.py
/usr/local/bin/python$PYTHON_MAJOR get-pip.py

# Finish installation
rm -rf $TMP_PATH
ln -s /usr/local/bin/python2.7 /usr/local/bin/python
ln -s /usr/local/bin/pip /usr/bin/pip

pip install virtualenv

#How to uninstall
make uninstall

以上是关于sh 在CentOS 7上安装本地Python 2.7.10的主要内容,如果未能解决你的问题,请参考以下文章

sh 在centos 7上安装python3.6.0

sh 在centos上安装docker(在Centos 7上测试)

如何安装Python 3中,并设置本地编程环境在CentOS 7

sh 如何在CentOS 7上安装Pip

sh 在Centos 7(CPU)上安装Tensorflow服务

sh 在Centos 7实例上安装Docker Engine