CentOS7打包PyInstaller出现OSError问题解决方案

这篇博客主要讲述了在遇到Python运行时找不到库文件libpython3.7m.so.1.0的问题时,如何通过重新配置和安装Python来解决。作者指出在CentOS系统中不需要像Debian/Ubuntu那样安装python3-dev,并详细指导了使用`./configure --prefix=/usr/local/python3 --enable-shared`参数重新编译Python,以及后续的`ldconfig`配置步骤,以确保Python能正确找到共享库。
部署运行你感兴趣的模型镜像

先上报错情况


```powershell
OSError: Python library not found: libpython3.7m.so.1.0, libpython3.7mu.so.1.0, libpython3.7.so.1.0
This would mean your Python installation doesn't come with proper library files.
This usually happens by missing development package, or unsuitable build parameters of Python installation.

* On Debian/Ubuntu, you would need to install Python development packages
* apt-get install python3-dev
* apt-get install python-dev
* If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)
首先,centos下不需要python3-dev,因为压根没有,那个是Debian/Ubuntu下才有的,所以先不考虑,
然后看**OSError: Python library not found: libpython3.7m.so.1.0**找不到这个,这个是重点,一会要解决。再看这个提示--enable-shared,让我们安装的时候带上这个参数,因为安装python的时候,我没有加,所以,要重装Python,使用

`./configure --prefix=/usr/local/python3 --enable-shared`
然后`make && make install`就好了

现在再次打开python的时候,会报错,
~~ImportError: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory~~ 
需要使用

```powershell

echo "/usr/local/python3/lib/" >> /etc/ld.so.conf
ldconfig 
```powershell
然后运行,ok,可以运行,打包也没问题了
新手发文,不太会排版,抱歉

您可能感兴趣的与本文相关的镜像

Python3.11

Python3.11

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值