zl程序教程

您现在的位置是:首页 >  后端

当前栏目

pyinstaller打包报错OSError: Python library not found: libpython3.7mu.so.1.0, libpython3.7m.so

Python打包 报错 not found library So Pyinstaller
2023-09-11 14:18:28 时间

pyinstaller打包报错

问题出现背景

  1. pyinstaller打包报错OSError: Python library not found: libpython3.7mu.so.1.0, libpython3.7m.so
  2. 环境是ubuntu18.04,打包是在virtualvenv生成的虚拟环境中进行的
  3. python3.7是我自己通过apt-get方式安装的,且系统自带的python是3.6的版本。

解决方式

我注意到报错提示内容中有这样一段文字

This means your Python installation does not come with proper shared library files.
This usually happens due to missing development package, or unsuitable build parameters of the Python installation.

* On Debian/Ubuntu, you need to install Python development packages:
  * apt-get install python3-dev
  * apt-get install python-dev
* If you are building Python by yourself, rebuild with `--enable-shared` (or, `--enable-framework` on macOS)`

于是我试了一下命令 apt-get install python3-dev ,但是发现安装的依然是系统自带3.6版本的依赖,所以我尝试了以下命令,结果发现是可行的,也解决了这个问题,如果是其他python版本例如 3.8,3.9的话,替换以下命令中的版本号应该也是可行的

sudo apt-get install python3.7-dev