一个80后
程序员的笔记

[Centos]安装Python

打开:https://www.python.org/downloads/

注:如果这里要安装vj插件,只能使用3.7.X版本,3.8暂时不兼容

下载:Download Python3

wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
xz -d Python-3.6.5.tar.xz
tar xvf Python-3.6.5.tar
cd Python-3.6.5
./configure --prefix=/usr/local/python3.6.5 --enable-optimizations --enable-shared
make
sudo cp libpython3.6m.so.1.0 /usr/lib/
sudo cp libpython3.6m.so.1.0 /usr/lib64/
##如果是3.7+会报错:ModuleNotFoundError: No module named '_ctypes'  这时候安装
##yum install libffi-devel -y
sudo make install && make distclean
sudo ln -s /usr/local/python3.6.5/ /usr/local/python3.6
sudo ln -s /usr/local/python3.6 /usr/local/python3
cd /usr/bin/
ln -sf /usr/local/python3/bin/python3 /usr/bin/python3.7
ln -sf /usr/bin/python3.7 /usr/bin/python3
ln -sf /usr/local/python3/bin/pip3 /usr/bin/pip3
ln -sf /usr/local/python3/bin/python3.7-config /usr/bin/python3.7-config

下载:Download Python2

wget https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tar.xz
xz -d Python-2.7.14.tar.xz
tar xvf Python-2.7.14.tar
cd Python-2.7.14
./configure --prefix=/usr/local/python2.7.14 --enable-optimizations --enable-shared

make
cp libpython2.7.so.1.0 /usr/lib/.
cp libpython2.7.so.1.0 /usr/lib64/.
sudo make install && make distclean
ln -sf /usr/local/python-2.7.15/ /usr/local/python2.7
ln -sf /usr/local/python2.7/ /usr/local/python2
ln -sf /usr/local/python2 /usr/local/python
cd /usr/bin/
ln -sf /usr/local/python2/bin/python /usr/bin/python2.7
ln -sf /usr/bin/python2.7 /usr/bin/python2
ln -sf /usr/bin/python2 /usr/bin/python
ln -sf /usr/local/python/include/python2.7/ /usr/include/.

ln -sf /usr/local/python2/bin/python2-config /usr/bin/python2-config
ln -sf /usr/bin/python2-config /usr/bin/python-config

ln -sf /usr/local/python2/include/python2.7/* /usr/include/.
#安装pip
yum -y install python-pip
#或者
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py

三方扩展:

ez_setup-0.9.tar.gz、PyYAML-3.12.tar.gz、zdaemon-4.2.0.tar.gz
sudo yum install libyaml-devel
sudo /usr/local/Python2.7.14/bin/python2.7 setup.py install
赞(2) 打赏
未经允许不得转载:笨笨天地 » [Centos]安装Python
分享到: 更多 (0)

相关推荐

  • 暂无文章

评论 1

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏