CentOS   发布时间:2022-04-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Centos安装python3-2大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

前言: python3应该是python的趋势所在,当然目前争议也比较大,这篇随笔的主要目的是记录在linux64下搭建python3环境的过程 以及碰到的问题和解决过程。   另外,如果本机安装了python2,尽量不要管他,使用python3运行python脚本就好,因为可能有程序依赖目前的python2环境, 比如yum!!!!! 不要动现有的python2环境! 不要动现有的python2

前言:

python3应该是python的趋势所在,当然目前争议也比较大,这篇随笔的主要目的是记录在linux64下搭建python3环境的过程

以及碰到的问题和解决过程。

  另外,如果本机安装了python2,尽量不要管他,使用python3运行python脚本就好,因为可能有程序依赖目前的python2环境,

比如yum!!!!!

不要动现有的python2环境!

不要动现有的python2环境!

不要动现有的python2环境!

重要的使用说三遍!

一、安装python3.6

下载python3.6安装包:

wget --no-check-certificate https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz

解压到当前目录:

tar -zxvf Python-3.6.0.tgz

cd Python-3.6.0
其中一条
./configure --prefix=/usr/local/python3.5 --enable-shared
./configure --prefix=/usr/local/python3.5 --enable-optimizations(系统推荐)


make & make install
# 不要复制,用手去敲
ln -s /usr/local/python3.5/bin/python3 /usr/bin/python3

此时运行python3命令的话会报错,缺少.so文件,我们需要进行如下操作:

cp -R /usr/local/python3.5/lib/* /usr/lib64/

ok!此时python3的基础环境已经安装完成!

二、安装pip以及setuptools

1、安装pip前需要前置安装setuptools(基础包)

wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26

tar -zxvf setuptools-19.6.tar.gz

cd setuptools-19.6

python3 setup.py build

python3 setup.py install

报错:RuntimeError: Compression requires the (missing) zlib module

我们需要在linux中安装zlib-devel包,进行支持

yum install zlib-devel

需要对python3.6进行重新编译安装。

cd python3.6

make & make install

又是漫长的编译安装过程。

重新安装setuptools

python3 setup.py build

python3 setup.py install

2、安装pip(管理包)

wget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb

tar -zxvf pip-8.0.2.tar.gz

cd pip-8.0.2

python3 setup.py build

python3 setup.py install

如果没有意外的话,pip安装完成。

 

3.安装virtualenv(虚拟环境)

pip install virtualenv

报错:pip is configured with LOCATIOns that require TLS/SSL,however the ssl module in python is not available.
CollecTing xxx
Could not fetch URL https://pypi.python.org/simple/xxxx/: There was a problem confirming the ssl certificate: Can’t connect to httpS URL because the SSL module is not available. - skipping
Could not find a version that satisfies the requirement xxx (from versions: )
No matching diStribution found for xxx


3.1.查看openssl安装包,发现缺少openssl-devel包
[[email protected] ~]# rpm -aq|grep openssl
openssl-0.9.8e-20.el5
openssl-0.9.8e-20.el5

3.2.yum安装openssl-devel
[[email protected] ~]# yum install openssl-devel -y

继续重新编译安装python3.6

ok,完成安装

 


python 报错:python3.6安装报错 configure: error: no acceptable C compiler found in $PATH

安装python的时候出现如下的错误:

[[email protected] ~]#./configure --prefix=/usr/local/python3.6?

checking build system type... i686-pc-linux-gnu

checking host system type... i686-pc-linux-gnu
checking for --enable-universalsdk... no
checking for --with-universal-archs... 32-bit
checking MACHDEP... linux
checking for --without-gcc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/src/pythonSoft/Python-3.3.4‘:
configure: error: no acceptable C compiler found in $PATH
See `config.log‘ for more details

 

由于本机缺少gcc编译环境

1、通过yum安装gcc编译环境:yum?install -y?gcc

2、本机没有安装yum功能,可下载gcc安装包:https://gcc.gnu.org/

大佬总结

以上是大佬教程为你收集整理的Centos安装python3-2全部内容,希望文章能够帮你解决Centos安装python3-2所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。