Python3.7.2安装

初始依赖包

yum install -y openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc libffi-devel libcurl-devel

下载源码包

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

解压安装

tar -zxf Python-3.7.2.tgz 
cd Python-3.7.2
./configure --prefix=/usr/local/python3
make && make install

安装完之后添加软链接,方便使用命令

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

错误处理

安装python3.11.1后使用pip3安装模块会报如下错误

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

解决方案; 手动安装较新版本的openssl

wget http://www.openssl.org/source/openssl-1.1.1.tar.gz --no-check-certificate
tar -zxvf openssl-1.1.1.tar.gz
cd openssl-1.1.1
./config --prefix=/usr/local/openssl shared zlib
make
make install

rm -rf /usr/bin/openssl
rm -rf /usr/lib64/libssl.so.1.1
rm -rf /usr/lib64/libcrypto.so.1.1

ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/
ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/
openssl version

重新编译安装Python,配置时指定openssl新版本的位置 重新配置需要加上--enable-optimizations参数


安装scrapy

遇到如下错误

Could not find a version that satisfies the requirement Twisted>=13.1.0 (from scrapy) (from versions: ) No matching distribution found for Twisted>=13.1.0 (from scrapy)

是因为没安装Twisted或版本低于13.1.0 到 https://pypi.org/ 搜索、下载源码包来安装

我这里下载的是Twisted-18.9.0.tar.bz2

最后更新于