简体   繁体   English

pyinstaller 错误:OSError:找不到 Python 库:libpython3.4mu.so.1.0、libpython3.4m.so.1.0、libpython3.4.so.1.0

[英]pyinstaller error: OSError: Python library not found: libpython3.4mu.so.1.0, libpython3.4m.so.1.0, libpython3.4.so.1.0

I'm using Python 3.4.4 on Centos7.我在 Centos7 上使用 Python 3.4.4。

I've created a python program on my local machine that makes use of qt modules.我在本地机器上创建了一个使用 qt 模块的 python 程序。 The program is running fine on my local machine.该程序在我的本地机器上运行良好。 I'm now trying to create an executable with pyinstaller.我现在正在尝试使用 pyinstaller 创建一个可执行文件。 I'm using the command:我正在使用命令:

pyinstaller main.py

I'm getting the following output:我得到以下输出:

40 INFO: PyInstaller: 3.2.1
40 INFO: Python: 3.4.4
41 INFO: Platform: Linux-3.10.0-327.36.3.el7.x86_64-x86_64-with-centos-7.3.1611-Core
41 INFO: wrote /home/neilharris/Documents/Python_Projects/transcoder/main.spec
42 INFO: UPX is not available.
44 INFO: Extending PYTHONPATH with paths
['/home/neilharris/Documents/Python_Projects/transcoder',
 '/home/neilharris/Documents/Python_Projects/transcoder']
44 INFO: checking Analysis
44 INFO: Building Analysis because out00-Analysis.toc is non existent
44 INFO: Initializing module dependency graph...
45 INFO: Initializing module graph hooks...
47 INFO: Analyzing base_library.zip ...
1869 INFO: Processing pre-find module path hook   distutils
3030 INFO: running Analysis out00-Analysis.toc
3039 INFO: Caching module hooks...
3046 INFO: Analyzing /home/neilharris/Documents/Python_Projects/transcoder/main.py
3089 INFO: Loading module hooks...
3089 INFO: Loading module hook "hook-xml.py"...
3353 INFO: Loading module hook "hook-encodings.py"...
3437 INFO: Loading module hook "hook-PyQt4.py"...
3438 INFO: Loading module hook "hook-distutils.py"...
3440 INFO: Loading module hook "hook-PyQt4.QtCore.py"...
3575 INFO: Loading module hook "hook-pydoc.py"...
3576 INFO: Loading module hook "hook-PyQt4.QtGui.py"...
3849 INFO: Looking for ctypes DLLs
3861 INFO: Analyzing run-time hooks ...
3867 INFO: Including run-time hook 'pyi_rth_qt4plugins.py'
3877 INFO: Looking for dynamic libraries
ldd: warning: you do not have execution permission for `/usr/local/lib/python3.4/site-packages/PyQt4/QtGui.so'
ldd: warning: you do not have execution permission for `/usr/local/lib/python3.4/site-packages/PyQt4/QtCore.so'
5115 INFO: Looking for eggs
5115 INFO: Python library not in binary depedencies. Doing additional searching...
Traceback (most recent call last):
  File "/usr/local/bin/pyinstaller", line 9, in <module>
    load_entry_point('PyInstaller==3.2.1', 'console_scripts', 'pyinstaller')()
  File "/usr/local/lib/python3.4/site-packages/PyInstaller/__main__.py", line 90, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "/usr/local/lib/python3.4/site-packages/PyInstaller/__main__.py", line 46, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "/usr/local/lib/python3.4/site-packages/PyInstaller/building/build_main.py", line 788, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "/usr/local/lib/python3.4/site-packages/PyInstaller/building/build_main.py", line 734, in build
    exec(text, spec_namespace)
  File "<string>", line 16, in <module>
  File "/usr/local/lib/python3.4/site-packages/PyInstaller/building/build_main.py", line 212, in __init__
    self.__postinit__()
  File "/usr/local/lib/python3.4/site-packages/PyInstaller/building/datastruct.py", line 161, in __postinit__
    self.assemble()
  File "/usr/local/lib/python3.4/site-packages/PyInstaller/building/build_main.py", line 543, in assemble
    self._check_python_library(self.binaries)
  File "/usr/local/lib/python3.4/site-packages/PyInstaller/building/build_main.py", line 626, in _check_python_library
    raise IOError(msg)
OSError: Python library not found: libpython3.4m.so.1.0, libpython3.4mu.so.1.0, libpython3.4.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)

Does anyone know what the issue could be?有谁知道问题可能是什么? Just to say I have python3-devel and python-devel installed (in relation to the suggestion at the end of the printed output.) Thanks只是说我安装了 python3-devel 和 python-devel (与打印输出末尾的建议有关。)谢谢

for Linux system like your CentOS , try rebuild python to generated shared lib using:对于像CentOS这样的 Linux 系统,尝试使用以下命令重建 python 以生成共享库:

env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.4.4

as said in pyenv offical doc正如pyenv官方文档中所说

You must install python-dev for your python's version你必须为你的 python 版本安装 python-dev

for example:例如:

Debian/Ubuntu - Python 2.7 ---> python2.7-dev Debian/Ubuntu - Python 2.7 ---> python2.7-dev

CentOs/RedHat - Python 3.4 ---> python34-devel CentOs/RedHat - Python 3.4 ---> python34-devel

CentOs/RedHat - Python 2.7 ---> python27-devel CentOs/RedHat - Python 2.7 ---> python27-devel

One of these errors can be puzzling, however: IOError("Python library not found!") PyInstaller needs to bundle the Python library, which is the main part of the Python interpreter, linked as a dynamic load library.然而,这些错误之一可能令人费解: IOError("Python library not found!") PyInstaller 需要捆绑 Python 库,它是 Python 解释器的主要部分,链接为动态加载库。 The name and location of this file varies depending on the platform in use.此文件的名称和位置因使用的平台而异。 Some Python installations do not include a dynamic Python library by default (a static-linked one may be present but cannot be used).默认情况下,某些 Python 安装不包含动态 Python 库(静态链接的库可能存在但无法使用)。 You may need to install a development package of some kind.您可能需要安装某种开发包。 Or, the library may exist but is not in a folder where PyInstaller is searching.或者,该库可能存在但不在 PyInstaller 正在搜索的文件夹中。

The places where PyInstaller looks for the python library are different in different operating systems, but /lib and /usr/lib are checked in most systems. PyInstaller查找python库的地方在不同的操作系统中是不同的,但在大多数系统中都会检查/lib和/usr/lib。 If you cannot put the python library there, try setting the correct path in the environment variable LD_LIBRARY_PATH in Linux or DYLD_LIBRARY_PATH in OS X.如果您不能将 python 库放在那里,请尝试在 Linux 中的环境变量 LD_LIBRARY_PATH 或 OS X 中的 DYLD_LIBRARY_PATH 中设置正确的路径。

Reference 参考

I have solved this in the way below:我已经通过以下方式解决了这个问题:

1st.第一。 check your system if it has libpython3.4m.so.1.0.检查您的系统是否有 libpython3.4m.so.1.0。 If yes, go to step 2nd.如果是,请转到第 2 步。 If no, download it(I'm using anaconda python, so I have it in anaconda folder.)如果没有,请下载它(我正在使用 anaconda python,所以我将它放在 anaconda 文件夹中。)

2nd.第二。 sudo cp /folder/to/your/libpython3.4m.so.1.0 /usr/lib

For developers who may face this issue, easily use conda virtual environments, by this you can specify the exact python version you need and there are not any concerns about libs!对于可能遇到此问题的开发人员,可以轻松使用 conda 虚拟环境,这样您就可以指定所需的确切 python 版本,而不必担心 libs! just install conda and create a new virtual environment with this command: conda create -n your_env_name python=needed_python_version(eg3.7.4)只需安装 conda 并使用以下命令创建一个新的虚拟环境: conda create -n your_env_name python=needed_python_version(eg3.7.4)

通过运行以下命令解决了 Ubuntu 16.04 的此问题:

  1. sudo add-apt-repository ppa:deadsnakes\/ppa<\/li><\/ol>
    • 请检查上述 ppa 是否仍然有效,否则添加最新的 ppa 。<\/li>
    • 如果您收到“未添加用户或项目”错误,则可能是防火墙问题,因此请联系您的 IT 管理员以解除对所需站点的阻止。<\/li><\/ul>
      1. sudo apt-get 更新<\/li>
      2. sudo apt-get install python3.6<\/li>
      3. sudo apt-get install python3.6-dev<\/li>
      4. pip3 安装 pyinstaller<\/li><\/ol>"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OSError: Python library not found: libpython3.9mu.so.1.0, libpython3.9m.so, etc., when running pyinstaller - OSError: Python library not found: libpython3.9mu.so.1.0, libpython3.9m.so, etc., when running pyinstaller python:加载共享库时出错:libpython3.4m.so.1.0:无法打开共享对象文件:没有这样的文件或目录 - python: error while loading shared libraries: libpython3.4m.so.1.0: cannot open shared object file: No such file or directory 错误加载 Python 库 libpython3.6m.so.1.0 pyinstaller Ubuntu Python - Error loading Python lib libpython3.6m.so.1.0 pyinstaller Ubuntu Python yum未找到libpython2.7.so.1.0()(64bit) - libpython2.7.so.1.0()(64bit) not found by yum Azure Function Python 导入错误:libpython3.6m.so.1.0 - Azure Function Python Import Error : libpython3.6m.so.1.0 Python3.7:加载共享库时出错:libpython3.7m.so.1.0 - Python3.7: error while loading shared libraries: libpython3.7m.so.1.0 Pyinstaller:无法打开共享对象 libpython3.5m.so.1.0 - Pyinstaller: Cannot open shared object libpython3.5m.so.1.0 在Python 2.7.13 Heroku dynos上缺少libpython2.7.so.1.0 - Missing libpython2.7.so.1.0 on Python 2.7.13 Heroku dynos 加载 Python lib '/tmp/_MEItueAuk/libpython3.7m.so.1.0' 时出错:dlopen: /lib/x86_64-linux-gnu/libc.so.6: 找不到版本 'GLIBC_2.28' - Error loading Python lib '/tmp/_MEItueAuk/libpython3.7m.so.1.0': dlopen: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found 加载共享库 libpython3.7m.so.1.0 时出错:没有这样的文件或目录(/usr/local/bin/coverage 需要) - Error loading shared library libpython3.7m.so.1.0: No such file or directory (needed by /usr/local/bin/coverage)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM