当前位置: 代码迷 >> 综合 >> pyinstaller 出现 OSError: Python library not found
  详细解决方案

pyinstaller 出现 OSError: Python library not found

热度:29   发布时间:2023-11-23 01:26:36.0

想使用pyinstaller隐藏代码部署时 ,遇到报错 

具体报错如下:
 

Traceback (most recent call last):File "/usr/local/python374/bin/pyinstaller", line 10, in <module>sys.exit(run())File "/usr/local/python374/lib/python3.7/site-packages/PyInstaller/__main__.py", line 111, in runrun_build(pyi_config, spec_file, **vars(args))File "/usr/local/python374/lib/python3.7/site-packages/PyInstaller/__main__.py", line 63, in run_buildPyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)File "/usr/local/python374/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 844, in mainbuild(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))File "/usr/local/python374/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 791, in buildexec(code, spec_namespace)File "/run/projects/simulate_area/bi_for_/console_.spec", line 17, in <module>noarchive=False)File "/usr/local/python374/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 243, in __init__self.__postinit__()File "/usr/local/python374/lib/python3.7/site-packages/PyInstaller/building/datastruct.py", line 158, in __postinit__self.assemble()File "/usr/local/python374/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 575, in assembleself._check_python_library(self.binaries)File "/usr/local/python374/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 681, in _check_python_libraryraise IOError(msg)
OSError: Python library not found: libpython3.7m.so.1.0, libpython3.7.so.1.0, libpython3.7m.so, libpython3.7mu.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)

于是先安装 python3-devel,

yum install python3-devel

完成后仍然报错,我是自己编译的python,于是尝试重新编译:

rm -rf Python-3.7.4
tar -xzf Python-3.7.4.tgz 
cd Python-3.7.4
./configure --prefix=/usr/local/python374 --enable-optimizations --with-openssl=/usr/local/openssl --enable-shared
make && make install

开启--enable-shared后会报 找不到so的错误 解决如下:

echo "/usr/local/python374/lib/" >> /etc/ld.so.conf
ldconfig 

之后再使用pyinstaller console_.py ok

  相关解决方案