enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.28k stars 282 forks source link

ModuleNotFoundError: No module named 'traitsui.qt4' And ModuleNotFoundError: No module named 'pyface.ui.null' #1258

Open Roly83 opened 1 year ago

Roly83 commented 1 year ago

Hola a todos he creado una aplicación con Mayavi y quiero convertirla en un ejecutable . exe y me genera un error de tras del otro y no logro solucionarlo y no sé qué hacer así que pido ayuda por si alguien me puede indicar como solucionarlo o donde puedo encontrar la solución. Gracias Traceback (most recent call last): File "pyface\base_toolkit.py", line 219, in import_toolkit File "importlib\metadata__init.py", line 162, in load File "importlib\init.py", line 126, in import_module File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 992, in _find_and_load_unlocked File "", line 241, in _call_with_frames_removed File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1004, in _find_and_load_unlocked ModuleNotFoundError: No module named 'pyface.ui.null' y luego cuando creo solucionar ese error me salta otro: Traceback (most recent call last): File "pyface\base_toolkit.py", line 219, in import_toolkit File "importlib\metadata\init.py", line 162, in load File "importlib\init__.py", line 126, in import_module File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1004, in _find_and_load_unlocked ModuleNotFoundError: No module named 'traitsui.qt4' por favor que alguien me diga cómo solucionar estos errores o donde puedo encontrar información para solucionarlo. gracias

corranwebster commented 1 year ago

In the short-term you should be able to avoid this error by setting the environment variable ETS_QT4_IMPORTS to a non-null value. For more information, see the Pyface documentation: https://docs.enthought.com/pyface/toolkits.html#toolkit-objects

Roly83 commented 1 year ago

A corto plazo, debería poder evitar este error configurando la variable de entorno ETS_QT4_IMPORTSen un valor no nulo. Para obtener más información, consulte la documentación de Pyface: https://docs.enthought.com/pyface/toolkits.html#toolkit-objects

Ante todo gracias por responderme. Debo decirle que soy bastante novato en la programación apenas estoy aprendiendo y hay muchas cosas que para cualquier programador puedan ser normales para mí pues son completamente desconocidas. No puedo configurar la variable de entorno ETS_QT4_IMPORTS ya que por más que he tratado de buscar soluciones me es imposible instalar QT4 en mi sistema no he podido hacerlo. De todas formas gracias por responderme he intentar ayudarme. Seguiré buscando alternativas para mí problema

corranwebster commented 1 year ago

The "qt4" is not directly referring to PyQt4, but rather to where the code is found in the Python modules in TraitsUI. So this will work with PyQt5, PySide2 or PySide6 (but unfortunately not PySide6 at the moment).

One way to set an environment variable on Mac or Linux systems for a single command is to do something like:

ETS_QT4_IMPORTS=1 python my_script.py

but there are ways to set things more permanently that depend on the shell that you are using - frequently it is something like:

export ETS_QT4_IMPORTS=1

which will set it for the rest of the terminal session.

On Windows there is a control panel for setting environment variables found at Control Panel » System » Advanced » Environment Variables. They can also be set temporarily using the set command.

Roly83 commented 1 year ago

gracias nuevamente por responder. Yo utilizo Windows y ya he probado esas variantes que me sugiere sin lograr ningún resultado, aquí le dejo un enlace con unos Screenshot de como tengo configuradas las variables de entorno para si tiene algún tiempo las mire y me diga que estoy haciendo mal. https://www.mediafire.com/file/2mrhjfcn7cywjc1/Screenshot.zip/file

Roly83 commented 1 year ago

Tambien configuré un spec más o menos como pude y como entendí que no tengo ni idea si está bien o mal, pero bueno se lo dejo por aquí para que me diga que tan equivocado estoy. jajaja

-- mode: python ; coding: utf-8 --

block_cipher = None

a = Analysis(['CCMM.py'], pathex=['C:\Users\rolyv\Desktop\CC_MM'], binaries=[], datas=[], hiddenimports=[], hookspath=[], runtime_hooks=[], excludes=[], win_no_prefer_redirects=False, win_private_assemblies=False, cipher=block_cipher, noarchive=False)

packages_path = 'C:\Users\rolyv\AppData\Local\Programs\Python\Python310\Lib\site-packages'

hiddenimports = []

def collect_imports(path, prefix): hiddenimports.append(prefix) for file in os.listdir(path): if file in {'pycache', 'init.py', 'tests'}: continue child = f'{prefix}.{file}' file_path = os.path.join(path, file) if os.path.isdir(file_path): collect_imports(file_path, child) elif os.path.isfile(file_path) and file.endswith('.py'): hiddenimports.append(child[0:-len('.py')])

collect_imports(os.path.join(packages_path, 'pyface', 'ui', 'qt4'), 'pyface.ui.qt4') collect_imports(os.path.join(packages_path, 'traitsui', 'qt4'), 'traitsui.qt4')

a.hiddenimports = hiddenimports

pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(pyz, a.scripts, [], exclude_binaries=True, name='CCMM', debug=False, bootloader_ignore_signals=False, strip=False, upx=True, console=True )

coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, strip=False, upx=True, upx_exclude=[], name='CCMM')