欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

【centos7.5】源码编译安装python3.7,和使用国内阿里源 安装ipython3

程序员文章站 2024-03-08 10:14:40
...

从官网下载最新的python3.7的tar包。

此处我们使用curl命令从网络上下载文件,选项“-O” 表示:把文件下载到本地。

#此处我们使用curl命令从网络上下载文件。
#选项“-O” 表示:把文件下载到本地。

 wget -O https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
#解压文件:
tar xf Python-3.7.0.tar.xz
cd Python-3.7.0
#此时先安装python的依赖;
yum install bzip2-devel
yum install python-devel
yum install libffi-dev
yum install sqlite-devel
yum install libuuid-devel
yum install readline-devel
yum install mysql-devel

#然后配置安装环境,编译,在安装。
 ./configure --prefix=/opt/python/ ,安装: make && make install

#但是在安装成功后,再次安装ipython时:

pip3.7 install ipython   报错如下:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ”SSLError("Can't connect to HTTPS URL because the SSL module is not available.")“


#这时通过rpm -q openssl 确认openssl已经安装,而且路径完全正确,于是从网络上查找解决办法:
#终于找到大佬的解决办法:http://ju.outofmemory.cn/entry/363322

#报错的意思是:缺少的openssl库,并不是只openssl库,而是另一个类似的开源而且更安全的libressl库,#于是从网络上下载libressl,然后源码安装

curl -O https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.7.4.tar.gz

#然后 
tar xf libressl-2.7.4.tar.gz
cd libressl-2.7.4
./configure --prefix=/usr/local/libressl(填写自己本地路径)
make && make install

#然后,再次重新配置python3.7(此时要添加参数 --with-openssl=),make && make install

cd Python-3.7.0
./configure --prefix=/opt/python/(填写自己本地路径)  --with-openssl=/usr/local/libressl(填写自己本地路径)

#然后:
make && make Install

#待一切安装结束后:
#执行如下:(从国内的阿里源下载ipython,速度更快,毕竟国外的源可能无法访问)
pip3.7 install ipython -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

#最后,输入ipython3,系统提示如下:


Python 3.7.0 (default, Sep 12 2018, 15:54:02) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.5.0 -- An enhanced Interactive Python. Type '?' for help.

#成功!!!


 

相关标签: ipython python3.7