ValueError при создании exe с использованием cx_Freeze, включая PyQt5 - PullRequest
0 голосов
/ 11 февраля 2019

Я пытаюсь создать .exe , используя cx_Freeze.Когда я пытаюсь построить его, он выдает ошибку значения.Я не понимаю, что именно это значит.Как вы думаете, переустановка cx_Freeze может решить проблему?

setup.py выглядит следующим образом:

from cx_Freeze import setup, Executable
import os
import sys

base = None

if sys.platform == 'win32':
    base = 'Win32GUI'

exe = [Executable("main.py", base=base)]

os.environ['TCL_LIBRARY'] = r'C:\\Users\\dm\\AppData\\Local\\Programs\\Python\\Python36\\tcl\\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\\Users\\dm\\AppData\\Local\\Programs\\Python\\Python36\\tcl\\tk8.6'

options = {
'build_exe': {
    'includes': ['scipy.io', 'scipy.spatial.ckdtree'],
    'include_files': [r'C:\\Users\\dm\\AppData\\Local\\Programs\\Python\\Python36\\DLLs\\tcl86t.dll', r'C:\\Users\\dm\\AppData\\Local\\Programs\\Python\\Python36\\DLLs\\tk86t.dll',
                      r'C:\\Users\\dm\\AppData\\Local\\Programs\\Python\\Python36\\Lib\\site-packages\\pyqt5_tools\\platforms\\qwindows.dll'],
    'packages': ['pandas', 'numpy', 'scipy', 'pydub', 'librosa', 'PyQt5.QtCore', 'PyQt5.QtGui', 'PyQt5.QtWidgets',
                 'python_speech_features'],
    }
}

setup(name="GUI", version="1.0", description='To be added',
  options=options, executables=exe)

При сборке я получаю следующееошибка.

running build
running build_exe
Traceback (most recent call last):
  File "setup.py", line 38, in <module>
options=options, executables=exe)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\dist.py", line 349, in setup
distutils.core.setup(**attrs)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\distutils\core.py", line 148, in setup
dist.run_commands()
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\dist.py", line 219, in run
freezer.Freeze()
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\freezer.py", line 616, in Freeze
self.finder = self._GetModuleFinder()
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\freezer.py", line 340, in _GetModuleFinder
finder.IncludeModule(name)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 651, in IncludeModule
namespace = namespace)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 311, in _ImportModule
deferredImports, namespace = namespace)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 385, in _InternalImportModule
namespace = namespace)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 404, in _InternalImportModule
parentModule, namespace)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 417, in _LoadModule
namespace)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 486, in _LoadPackage
self._LoadModule(name, fp, path, info, deferredImports, parent)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 464, in _LoadModule
self._RunHook("load", module.name, module)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 537, in _RunHook
method(self, *args)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\hooks.py", line 567, in load_scipy
finder.IncludePackage("scipy.misc")
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 659, in IncludePackage
module = self._ImportModule(name, deferredImports)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 311, in _ImportModule
deferredImports, namespace = namespace)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 404, in _InternalImportModule
parentModule, namespace)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 417, in _LoadModule
namespace)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 486, in _LoadPackage
self._LoadModule(name, fp, path, info, deferredImports, parent)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 475, in _LoadModule
self._ScanCode(module.code, module, deferredImports)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 565, in _ScanCode
module, relativeImportIndex)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 346, in _ImportModule
deferredImports, namespace = namespace)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 404, in _InternalImportModule
parentModule, namespace)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 475, in _LoadModule
self._ScanCode(module.code, module, deferredImports)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 570, in _ScanCode
fromList, deferredImports)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 211, in _EnsureFromList
self._ImportModule(subModuleName, deferredImports, caller)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 311, in _ImportModule
deferredImports, namespace = namespace)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 404, in _InternalImportModule
parentModule, namespace)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 475, in _LoadModule
self._ScanCode(module.code, module, deferredImports)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 589, in _ScanCode
topLevel = False)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 589, in _ScanCode
topLevel = False)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 570, in _ScanCode
fromList, deferredImports)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 211, in _EnsureFromList
self._ImportModule(subModuleName, deferredImports, caller)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 311, in _ImportModule
deferredImports, namespace = namespace)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 404, in _InternalImportModule
parentModule, namespace)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 475, in _LoadModule
self._ScanCode(module.code, module, deferredImports)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 565, in _ScanCode
module, relativeImportIndex)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 311, in _ImportModule
deferredImports, namespace = namespace)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 404, in _InternalImportModule
parentModule, namespace)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 464, in _LoadModule
self._RunHook("load", module.name, module)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\finder.py", line 537, in _RunHook
method(self, *args)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\hooks.py", line 526, in load_PyQt4_QtGui
name, QtCore = _qt_implementation(module)
  File "C:\Users\dm\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\hooks.py", line 437, in _qt_implementation
_qtcore = __import__(name, fromlist=['QtCore']).QtCore
ValueError: PyCapsule_GetPointer called with incorrect name

Любая помощь приветствуется.

1 Ответ

0 голосов
/ 13 февраля 2019

Ваш скрипт установки включает в себя файлы и пакеты, принадлежащие tkinter и PyQt5, а выложенная трассировка стека показывает, что скрипт установки потерпел неудачу при выполнении перехвата загрузки PyQt4, что предполагает, что ваш основнойскрипт импортирует PyQt4 куда-нибудь.Выберите одну из графических библиотек из tkinter, PyQt4 и PyQt5 и используйте только выбранную библиотеку в сценариях main и setup.

Вы можете добавить библиотеки, которые вы не используете, к 'excludes' элемент списка в словаре опций build_exe, который указывает cx_Freeze не включать их.

...