暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Python3/pip aarch64上的离线安装

济南小老虎 2024-04-05
1120

背景

2021年底总结过一版本, 想着这次重新梳理一下
主要是ARM机器上面的过程.

发现里面一个深坑.
python3.11 跟python3.9 不一样
无法使用libssl openssl1.1.1s
我这边直接使用 openssl3.2.1 才可以正常编译安装

这一块网上资料比较少比较坑.


第一步下载

需要说明 2024.4时最新版本已经是python3.13
但是为了稳定性与兼容性, 我准备使用 3.11.9 的版本
之前的版本是 3.9 本次进行一次升级工作.

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


安装必备的依赖

yum install libffi-devel tcl-devel tk-devel perl-CPAN -y
yum groups install "Development Tools" -y
wget https://github.com/openssl/openssl/releases/download/openssl-3.2.1/openssl-3.2.1.tar.gz

tar -zxvf openssl-3.2.1.tar.gz && cd openssl-3.2.1
./config --prefix=/opt/openssl && make && make install


打包python

tar -zxvf Python-3.11.9.tgz && cd Python-3.11.9
time ./configure --with-openssl=/opt/openssl --prefix=/opt/python3 --enable-optimizations


注意需要修改 Modules/Setup的文件
将:
To statically link OpenSSL:

下面的四行修改为如下: 注意是取消注释

# To statically link OpenSSL:
_ssl _ssl.c $(OPENSSL_INCLUDES) $(OPENSSL_LDFLAGS) \
-l:libssl.a -Wl,--exclude-libs,libssl.a \
-l:libcrypto.a -Wl,--exclude-libs,libcrypto.a
_hashlib _hashopenssl.c $(OPENSSL_INCLUDES) $(OPENSSL_LDFLAGS) \
-l:libcrypto.a -Wl,--exclude-libs,libcrypto.a

./configure --with-openssl=/opt/openssl --prefix=/opt/python3 --enable-optimizations

time make

make install



修改境内源

mkdir ~/.pip
cat > ~/.pip/pip.conf <<EOF
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn
EOF


/opt/python3/bin/python3 -m pip install --upgrade pip

安装pip包

/opt/python3/bin/pip3 install async-generator attrs bcrypt certifi cffi
/opt/python3/bin/pip3 install charset-normalizer cryptography ddt et-xmlfile h11 idna jdcal Mako
/opt/python3/bin/pip3 install MarkupSafe numpy opencv-python openpyxl outcome pandas paramiko
/opt/python3/bin/pip3 install Pillow PyAutoIt pycparser PyNaCl pyOpenSSL python-dateutil
/opt/python3/bin/pip3 install pytz PyYAML requests selenium setuptools six sniffio sortedcontainers
/opt/python3/bin/pip3 install trio trio-websocket urllib3 wsproto xlrd xlwt
/opt/python3/bin/pip3 install psycopg2


打包python的镜像文件

cd opt
tar -czvf python3_aarch64_tar.gz python3/

可以用来备用了.


文章转载自济南小老虎,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论