全部操作都在root用戶下執(zhí)行
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 #創(chuàng)建編譯安裝目錄
cd Python-3.7.0
./configure --prefix=/usr/local/python3
make && make install
4.創(chuàng)建軟連接
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
如上可能會出現(xiàn)如下報錯信息:
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 打包的執(zhí)行文件在另一臺機子上運行出錯结耀,錯誤如下:
[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