Centos 6.x 安装Python 3.4.3

python

[root@squid ~]# sed -i 's#keepcache=0#keepcache=1#g' /etc/yum.conf

[root@squid ~]# grep keepcache /etc/yum.conf 

keepcache=1

[root@squid ~]# ls /var/cache/yum/x86_64/6/base/packages/

yum groupinstall "Development tools"

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel


tar -Jxvf Python-3.4.3.tar.xz
mkdir /usr/local/python3
cd Python-3.4.3/

./configure --prefix=/usr/local/python3

make

make install

cd /usr/bin/

ln -s /usr/local/python3/bin/python3 /usr/bin/python3

ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3


[root@squid ~]# python -V

Python 2.6.6

[root@squid ~]# python3 -V

Python 3.4.3

[root@squid ~]# pip3

[root@squid ~]# python3

Python 3.4.3 (default, Jun 17 2016, 13:34:53)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> 


vim /usr/bin/yum

#!/usr/bin/python2.7

vim /usr/libexec/urlgrabber-ext-down

#! /usr/bin/python2.7



mv python python2.6

mv python python2.7


1. 准备

安装模块

# yum groupinstall "Development tools"

# yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel

Python3.4 安装

下载代码 configure → make → make altinstall

# cd /usr/local/src

# wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tgz

# tar -zxvf Python-3.4.3.tgz

# cd Python-3.4.3

# ./configure --prefix=/usr/local/python

# make && make altinstall

安装Python3.4 :公用库的安装

# echo "/usr/local/python/lib" >> /etc/ld.so.conf

# ldconfig

安装Python3.4: 4. /usr/local/bin/

# ln -s /usr/local/python/bin/python3.4 /usr/local/bin/python

安装Python3.4 :5. 确认是否安装正确

# /usr/local/python/bin/python3.4 -V

# python -V

安装Python3.4 Easy_Install

# cd /usr/local/src

# wget https://pypi.python.org/…/s/setuptools/setuptools-18.0.1.zip

# unzip setuptools-18.0.1.zip

# cd setuptools-18.0.1

# /usr/local/bin/python setup.py install

# ln -s /usr/local/python/bin/easy_install /usr/local/bin/easy_install

安装Python3.4 :Pip

# /usr/local/bin/easy_install pip

# ln -s /usr/local/python/bin/pip /usr/local/bin/pip

安装Python3.4: Virtualenv

# pip install virtualenv

# ln -s /usr/local/python/bin/virtualenv /usr/local/bin/virtualenv

安装Python3.4 :Virtualenvwrapper

# pip install virtualenvwrapper

安装Python3.4 :参数设定

$ vim ~/.bashrc

if [ -f /usr/local/python/bin/virtualenvwrapper.sh ]; then

export WORKON_HOME=$HOME/.virtualenvs

source /usr/local/python/bin/virtualenvwrapper.sh

fi




来自为知笔记(Wiz)



以上是 Centos 6.x 安装Python 3.4.3 的全部内容, 来源链接: utcz.com/z/387944.html

回到顶部