Centos7下安装使用Pyinstaller及Python library not found错误解决方法

Centos7下安装使用Pyinstaller及Python library not found错误解决方法

1.环境搭建:

  • 基于python3.6,Centos7

在这里插入图片描述

  • 安装Pyintaller
pip3 install pytinstall

安装结束后,如图所示:
在这里插入图片描述

  • 检验Pyinstall版本
pyinstaller --version

如图所示:
在这里插入图片描述

2.测试pyinstaller:

  • 出现类似如下情况:
...
...
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 
    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 "", line 16, in 
  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)
  • 解决方案(基于Centos):
yum install python36-devel
  • 其他Linux系统解决方案:
	Debian/Ubuntu - Python 2.7 ---> python2.7-dev

	CentOs/RedHat - Python 3.6 ---> python36-devel

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

3.成功解决,试运行:

ls查看当前目录下文件:
在这里插入图片描述
对htmlsession.py进行转换:

pyinstaller -F -p /usr/local/include/python3.6m/ htmlsession.py

出现如下信息,表示已经成功:

...
...
18135 INFO: checking EXE
18135 INFO: Building EXE because EXE-00.toc is non existent
18135 INFO: Building EXE from EXE-00.toc
18135 INFO: Appending archive to ELF section in EXE /root/fishtest/dist/htmlsession
18159 INFO: Building EXE from EXE-00.toc completed successfully.

在当前目录下的dist文件夹中,执行该可执行文件:
在这里插入图片描述成功!

你可能感兴趣的:(Centos,Python)