如何在 pipenv/pyenv 中使用 pyinstaller [英] How to use pyinstaller with pipenv / pyenv

查看:221
本文介绍了如何在 pipenv/pyenv 中使用 pyinstaller的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的 python 脚本中发送一个可执行文件,该脚本位于使用 pipenv 的虚拟环境中,它再次依赖 pyenv 进行 python 版本控制.为此,我想要我们 pyinstaller.

I am trying to ship an executable from my python script which lives inside a virtual environment using pipenv which again relies on pyenv for python versioning. For that, I want to us pyinstaller.

我做了什么:

pipenv install pyinstaller 
pyinstaller --onefile my_script.py

输出:

40 INFO: PyInstaller: 3.5
40 INFO: Python: 3.6.9
41 INFO: Platform: Linux-4.15.0-65-generic-x86_64-with-debian-stretch-sid
42 INFO: wrote /home/matthaeus/cybathlon/planvec/qt_video_gui_example.spec
44 INFO: UPX is not available.
45 INFO: Extending PYTHONPATH with paths
['/home/matthaeus/cybathlon/planvec', '/home/matthaeus/cybathlon/planvec']
45 INFO: checking Analysis
45 INFO: Building Analysis because Analysis-00.toc is non existent
45 INFO: Initializing module dependency graph...
46 INFO: Initializing module graph hooks...
47 INFO: Analyzing base_library.zip ...
2786 INFO: running Analysis Analysis-00.toc
2801 INFO: Caching module hooks...
2805 INFO: Analyzing /home/matthaeus/cybathlon/planvec/qt_video_gui_example.py
3284 INFO: Processing pre-find module path hook   distutils
3285 INFO: distutils: retargeting to non-venv dir '/home/matthaeus/.pyenv/versions/3.6.9/lib/python3.6/distutils/__init__.py'
3972 INFO: Processing pre-safe import module hook   setuptools.extern.six.moves
4336 INFO: Processing pre-find module path hook   site
4337 INFO: site: retargeting to fake-dir '/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/fake-modules'
6327 INFO: Loading module hooks...
6328 INFO: Loading module hook "hook-numpy.core.py"...
6458 INFO: Loading module hook "hook-sysconfig.py"...
6464 INFO: Loading module hook "hook-PyQt5.QtCore.py"...
6534 INFO: Loading module hook "hook-scipy.py"...
6535 INFO: Loading module hook "hook-PyQt5.py"...
6549 WARNING: Hidden import "sip" not found!
6549 INFO: Loading module hook "hook-pkg_resources.py"...
6788 INFO: Processing pre-safe import module hook   win32com
7015 INFO: Loading module hook "hook-numpy.py"...
7015 INFO: Loading module hook "hook-cv2.py"...
7016 INFO: Loading module hook "hook-PyQt5.QtGui.py"...
7048 INFO: Loading module hook "hook-PyQt5.QtWidgets.py"...
7096 INFO: Loading module hook "hook-pydoc.py"...
7097 INFO: Loading module hook "hook-xml.py"...
7150 INFO: Loading module hook "hook-encodings.py"...
7203 INFO: Loading module hook "hook-setuptools.py"...
7423 WARNING: Hidden import "distutils.command.build_ext" not found!
7680 INFO: Looking for ctypes DLLs
7762 INFO: Analyzing run-time hooks ...
7769 INFO: Including run-time hook 'pyi_rth_pyqt5.py'
7770 INFO: Including run-time hook 'pyi_rth_pkgres.py'
7771 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
7785 INFO: Looking for dynamic libraries
9784 INFO: Looking for eggs
9784 INFO: Python library not in binary dependencies. Doing additional searching...
Traceback (most recent call last):
  File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/bin/pyinstaller", line 8, in <module>
    sys.exit(run())
  File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 844, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 791, in build
    exec(code, spec_namespace)
  File "/home/matthaeus/cybathlon/planvec/qt_video_gui_example.spec", line 17, in <module>
    noarchive=False)
  File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 243, in __init__
    self.__postinit__()
  File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/building/datastruct.py", line 158, in __postinit__
    self.assemble()
  File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 575, in assemble
    self._check_python_library(self.binaries)
  File "/home/matthaeus/.local/share/virtualenvs/planvec-R86NQhbu/lib/python3.6/site-packages/PyInstaller/building/build_main.py", line 681, in _check_python_library
    raise IOError(msg)
OSError: Python library not found: libpython3.6mu.so.1.0, libpython3.6m.so, libpython3.6m.so.1.0, libpython3.6.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-dev 和 python-dev 安装,但没有运气.现在,我希望有人能告诉我这里发生了什么!

I tried the recommended python3-dev and python-dev installations without luck. Now, I hope someone can enlighten me what is going on here!

干杯,马特

推荐答案

您需要在启用 CPython 共享库的情况下进行构建.

You need to build with CPython shared-library enabled.

env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.6.9
eval "$(pyenv init -)"

参考:https://github.com/pyenv/pyenv/wiki

这篇关于如何在 pipenv/pyenv 中使用 pyinstaller的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆