• pyinstaller 打包遇到问题:Python library not found: libpython3.9m.so.1.0, libpython3.9m.so, libpython3.9.so.1.0, libpython3.9.so, libpython3.9mu.so.1.0


    背景

    • 在linux部署执行python脚本的时候,要避免因为依赖带来的问题,同时不想暴露自己的代码程序,可以用pyinstaller将py文件打包成一个可执行的文件

    操作

    • 安装pyinstaller
      pip install pyinstaller

    • 安装完成之后, 执行以下命令就会完成打包,在对应的目录下会生成一个dist目录,里面就是可执行的程序文件
      pyinstaller -F demo.py

    遇到问题

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

    在打包过程中遇到了打包不成功的问题,看报错事python缺少动态库,重点错误提示:
    * If you are building Python by yourself, rebuild with --enable-shared(or,--enable-framework on macOS)
    所以需要将python重新build,执行以下命令
    cd /usr/local/python3.9/ ./configure --prefix=/usr/local/python3.9 --enable-shared --with-ssl make &make install
    重新打包编译了python解释器,然后再执行以下, 将编译的依赖库拷贝到系统库中,
    cp libpython3.so libpython3.9.so.1.0 /usr/lib64/
    至此,就可以继续执行上面的打包命令了!

  • 相关阅读:
    Handler一般处理程序的应用--随机图片生成
    一个内外网部署sharepoint的配置
    不使用SQL Server Management Studio备份数据库的方法
    根据模板生成网页
    一个简单的将Oracle生产库定期备份到备份库的方法
    c#序列化与反序列化
    The Java Reliable Multicast Service:A Reliable Multicast Library
    Video capture using JMF
    转:关于Jxta的Advertisement
    Practical JXTA II
  • 原文地址:https://www.cnblogs.com/codeBang/p/15856571.html
Copyright © 2020-2023  润新知