centos6.9下安装python3.7
2024-10-19 23:42:20
说明
以下所有操作都基于centos6.9
python3.7依赖openssl1.0.2,首先更新系统自带的openssl
建议
升级系统到centos7(系统openssl已升级到1.0.2)
升级openssl
cd /ddhome/tools
wget -c https://www.openssl.org/source/openssl-1.0.2p.tar.gz
tar -xf /ddhome/src # 这里不能用-xzvf,否则python3.7装不了ssl模块
# 配置ssl
cd /ddhome/src
./config shared zlib # shared zlib也不可缺少
make && make install
mv /usr/bin/openssl /usr/bin/openssl-1.0.1e
mv /usr/include/openssl /usr/include/openssl-1.0.1e
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl/ /usr/include/openssl
# 添加库文件路径
#ln -s /usr/local/ssl/lib/libssl.so /usr/local/lib64/libssl.so
echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
#echo "/usr/local/lib64" >> /etc/ld.so.conf
# 替换老版本libssl.so软链接
[root@ddcvb openssl-1.0.2]# ll /usr/lib64/libssl.so
lrwxrwxrwx. 1 root root 16 Aug 25 15:22 /usr/lib64/libssl.so -> libssl.so.1.0.1e
[root@ddcvb openssl-1.0.2]# ll /usr/lib64/libssl.so.10
lrwxrwxrwx. 1 root root 16 Aug 23 04:36 /usr/lib64/libssl.so.10 -> libssl.so.1.0.1e
rm -rf /usr/lib64/libssl.so
ln -s /usr/local/ssl/lib/libssl.so /usr/lib64/libssl.so
# 刷新库文件
ldconfig -v
# 注意
/usr/lib64/libssl.so.10 不要删, python2.7用的就是它
# 查看版本
openssl version -a
安装依赖包
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
# 3.7必须安装
yum -y install libffi-devel
下载python3.7并配置
cd /ddhome/tools
wget -c https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
tar -xzvf Python-3.7.0 -C /ddhome/src
cd /ddhome/src
./configure
开启ssl
开启ssl模块,要不然pip安装https请求的所有模块都会失败,而且必须在make之前完成
先配置python,即先运行 ./configure, 会出现./Module/Setup文件
vim Module/Setup, 修改如下
# Socket module helper for socket(2)
_socket socketmodule.c timemodule.c
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
#SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
安装twisted
wget -c https://files.pythonhosted.org/packages/90/50/4c315ce5d119f67189d1819629cae7908ca0b0a6c572980df5cc6942bc22/Twisted-18.7.0.tar.bz2
tar jxvf Twisted-18.7.0.tar.bz2
python3 setup.py install
安装python3.7
cd /ddhome/src
make && make install
安装爬虫依赖包
pip3 install request selenium scrapy
安装图形编程接口
python的图形编程接口, 使用matplotlib做图时需要
# centos
yum install -y tkinter tk-devel
# ubuntu
sudo apt-get install python-tk
安装科学计算相关包
pip3 install matplotlib -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
pip3 install numpy -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
pip3 install pandas -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
pip3 install seaborn scipy -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
安装pyecharts
pip3 install pyecharts
# Geo Data extensions
pip3 install echarts-cities-pypkg
# Map extensions
pip3 install echarts-countries-pypkg
pip3 install echarts-china-provinces-pypkg
pip3 install echarts-china-cities-pypkg
pip3 install echarts-china-counties-pypkg
pip3 install echarts-china-misc-pypkg
pip3 install echarts-united-kingdom-pypkg
matplotlib图形化展示
_tkinter.TclError: no display name and no $DISPLAY environment variable
解决:首行加入下面两句话:
import matplotlib
# Force matplotlib to not use any Xwindows backend.
matplotlib.use('Agg')
最新文章
- HTTP、HTTP2
- listview控件及其与数据库的连接
- Java删除数据库中的数据
- Open Yale course:Listening to Music
- 优秀大数据GitHub项目一览
- HDU 2072 单词数
- Java的登陆验证问题
- Hyper-V网络虚拟化--VM之间拷贝速度慢
- golang io需要牢记的几个点
- 弹出框layer的使用封装
- eclipse如何查看类之间的引用关系
- outlook 当关闭时最小化到任务栏完美的解决方案
- hdu2993之斜率dp+二分查找
- 你需要知道的这几种 asp.net core 修改默认端口的方式
- BZOJ4530[Bjoi2014]大融合——LCT维护子树信息
- 文件二进制与String相互转换
- Mac下安装和配置Maven
- LeetCode 题解 56. Merge Intervals
- 【前端开发】利用Fiddler抓包工具进行本地调试
- Python3模块: hashlib
热门文章
- Linux工具-nmon
- SpringMVC笔记——SSM框架搭建简单实例
- 【转】15个必须知道的chrome开发者技巧
- sqlserver-一次updlock和withnolock和with check option 的报错原因分析
- Hadoop学习之路(十九)MapReduce框架排序
- [转]谈谈关于MVP模式中V-P交互问题
- Ubuntu安装PHP7
- disconf实践(一)Ubuntu16.04部署disconf
- HDU 1162Eddy's picture(MST问题)
- ActiveRecord初始化,可以实现jfinal系统启动完成后,再建立数据库连接