Python3(22):Centos7使用PyInstaller打包出现OSError: Python library not found

PyInstaller打包python程序

$pyinstaller -F casb_data.py

13496 INFO: Python library not in binary dependencies. Doing additional searching...

Traceback (most recent call last):

  File "/usr/local/python3/bin/pyinstaller", line 8, in <module>

    sys.exit(run())

  File "/usr/local/python3/lib/python3.8/site-packages/PyInstaller/__main__.py", line 114, in run

    run_build(pyi_config, spec_file, **vars(args))

  File "/usr/local/python3/lib/python3.8/site-packages/PyInstaller/__main__.py", line 65, in run_build

    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)

  File "/usr/local/python3/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 725, in main

    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))

  File "/usr/local/python3/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 672, in build

    exec(code, spec_namespace)

  File "/home/cg/app_hmf/python_tencent/casb_data.spec", line 6, in <module>

    a = Analysis(['casb_data.py'],

  File "/usr/local/python3/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 242, in __init__

    self.__postinit__()

  File "/usr/local/python3/lib/python3.8/site-packages/PyInstaller/building/datastruct.py", line 160, in __postinit__

    self.assemble()

  File "/usr/local/python3/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 476, in assemble

    self._check_python_library(self.binaries)

  File "/usr/local/python3/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 569, in _check_python_library

    python_lib = bindepend.get_python_library_path()

  File "/usr/local/python3/lib/python3.8/site-packages/PyInstaller/depend/bindepend.py", line 945, in get_python_library_path

    raise IOError(msg)

OSError: Python library not found: libpython3.8m.so, libpython3.8m.so.1.0, libpython3.8mu.so.1.0, libpython3.8.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)

查看错误:OSError: Python library not found: libpython3.8m.so, libpython3.8m.so.1.0, libpython3.8mu.so.1.0, libpython3.8.so.1.0

解决提示:

If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)

解决方法:

#进入下载的python安装包,解压缩目录,重新配置和编译执行

$cd /home/cg/Python-3.8.6

$./configure --prefix=/usr/local/python3 --enable-shared

出现上面情况:重新配置

$./configure --prefix=/usr/local/python3 --enable-framework

出现上面情况:重新配置

$./configure --prefix=/usr/local/python3 --enable-optimizations

这次终于配置完成了,再次编译和执行

$make && make install

 

再次执行打包程序

#进入python目录

$pyinstaller -F casb_data.py

提示:/usr/local/python3/bin/python3.8: error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file: No such file or directory

 

原因是因为python运行时没有加载到libpython3.8.so.1.0这个库文件,将其复制到响应目录

$cp /usr/local/python3/lib/libpython3.8.so.1.0 /usr/lib64/

 

重新执行打包程序-->执行OK,yet.

$pyinstaller -F casb_data.py

参考:https://blog.csdn.net/qq_37742059/article/details/103026800

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

宁宁可可

您的鼓励是我创作的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值