centos6.8 安装python2.7 or python3.6

from:https://danieleriksson.net/2017/02/08/how-to-install-latest-python-on-centos/

for ubuntu: https://askubuntu.com/questions/981118/correct-way-to-install-python-2-7-on-ubuntu-17-10/981279

准备

# Start by making sure your system is up-to-date:
yum update
# Compilers and related tools:
yum groupinstall -y "development tools"
# Libraries needed during compilation to enable all features of Python:
yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel expat-devel
# If you are on a clean "minimal" install of CentOS you also need the wget tool:
yum install -y wget

安装:

# Python 2.7.14:
wget http://python.org/ftp/python/2.7.14/Python-2.7.14.tar.xz
tar xf Python-2.7.14.tar.xz
cd Python-2.7.14
./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
make && make altinstall

# error while loading shared libraries: libpython2.7.so.1.0

ln -s /usr/local/python2.7/lib/libpython2.7.so /usr/lib  # link libpython2.7.so to /usr/lib/libpython2.7.so
ln -s /usr/local/python2.7/lib/libpython2.7.so.1.0 /usr/lib
ln -s /usr/local/python2.7/bin/python2.7 /usr/local/bin
# add /usr/local/bin, /usr/lib in /etc/ld.so.conf, 2 lines, just directory is enough
/sbin/ldconfig -v

# Python 3.6.3: 
wget http://python.org/ftp/python/3.6.3/Python-3.6.3.tar.xz
tar xf Python-3.6.3.tar.xz cd Python-3.6.3
.
/configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
make && make altinstall

 安装pip

# First get the script:
wget https://bootstrap.pypa.io/get-pip.py
 
# Then execute it using Python 2.7 and/or Python 3.6:
python2.7 get-pip.py
python3.6 get-pip.py
 
# With pip installed you can now do things like this:
pip2.7 install [packagename]
pip2.7 install --upgrade [packagename]
pip2.7 uninstall [packagename]

使用官方离线包安装,
cd setuptools
python2.7 setup.py install
cd pip
python2.7 setup.py install

 

转载于:https://www.cnblogs.com/buxizhizhoum/p/8117984.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值