全部操作都在root用户下执行
1.安装编译相关工具
yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum install libffi-devel -y
2.下载安装包解压
cd #回到用户目录
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar -xvJf Python-3.7.0.tar.xz
3.编译安装
mkdir /usr/local/python3 #创建编译安装目录
cd Python-3.7.0
./configure --prefix=/usr/local/python3
make && make install
4.创建软连接
ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
5.验证是否成功
python3 -V
pip3 -V
原文链接:https://www.cnblogs.com/anxminise/p/9650206.html
如上可能会出现如下报错信息:
python: error while loading shared libraries: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory
解决方法:
root@localhost lib]# cd /usr/local/bin/python3/lib
[root@localhost lib]# cp libpython3.7m.so.1.0 /usr/lib64
原文链接:https://blog.csdn.net/weixin_43840640/article/details/89478729
pyinstaller 打包的执行文件在另一台机子上运行出错,错误如下:
[root@hubrhel# ./main
Traceback (most recent call last):
File "main.py", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
File "tkinter/init.py", line 36, in <module>
ImportError: /tmp/_MEIICfyah/libX11.so.6: undefined symbol: xcb_poll_for_reply64
[13720] Failed to execute script main
解决方式如下:
Pyinstaller excludes the libxcb libraries. Check PyInstaller/depend/dylib.py - there you will find:
libxcb changes ABI frequently (e.g.: between Ubuntu LTS releases) and is libxcb-dri changes ABI frequently (e.g.: between Ubuntu LTS releases) and is usually installed as dependency of the graphics stack anyway. No need to bundle it.
... or check this commit, which has not made it into pyinstaller yet:https://github.com/pyinstaller/pyinstaller/commit/4a6d74a13122b763e99f97995fbbb1c6967769bb
Try to remove "r'/libxcb.so..*': 1," in PyInstaller/depend/dylib.py.
去除PyInstaller/depend/dylib.py文件中的libxcb.so相关的两个库 r'libxcb.so(..)?',r'libxcb-dri..so(..*)?'
然后重启设备,重新进行打包。程序运行正常。
原文链接:https://blog.csdn.net/LshuangCC/article/details/84664464