calculix / ccx2paraview

CalculiX to Paraview converter (frd to vtk/vtu). Makes possible to view and postprocess CalculiX analysis results in Paraview. Generates Mises and Principal components for stress and strain tensors.
GNU General Public License v3.0
84 stars 18 forks source link

ModuleNotFoundError: No module named 'writer' when attempting to use pyinstaller #24

Closed feacluster closed 2 years ago

feacluster commented 2 years ago

I am trying to create a faster a binary with pyinstaller but the executable errors out with "No module found...".. Here is my full output below if there is something obvious I am doing wrong:

[feacluster@micro ccx2paraview]$ ll
total 52
-rwxrwxr-x. 1 feacluster feacluster  3796 Dec  5 19:54 __init__.py
-rwxrwxr-x. 1 feacluster feacluster  8113 Dec  5 19:54 frd2vtk.py
-rwxrwxr-x. 1 feacluster feacluster  1809 Dec  5 19:54 clean.py
-rwxrwxr-x. 1 feacluster feacluster  6305 Dec  5 19:54 writer.py
-rwxrwxr-x. 1 feacluster feacluster 20802 Dec  5 19:54 reader.py
drwxrwxr-x. 2 feacluster feacluster   153 Dec  5 19:54 __pycache__
-rw-rw-r--. 1 feacluster feacluster  1129 Dec  5 20:04 __init__.spec
[feacluster@micro ccx2paraview]$ pyinstaller __init__.py --onedir
43 INFO: PyInstaller: 4.7
43 INFO: Python: 3.6.8
43 INFO: Platform: Linux-4.18.0-348.2.1.el8_5.x86_64-x86_64-with-centos-8
44 INFO: wrote /home/feacluster/.local/lib/python3.6/site-packages/ccx2paraview/__init__.spec
45 INFO: UPX is not available.
46 INFO: Extending PYTHONPATH with paths
['/home/feacluster/.local/lib/python3.6/site-packages']
176 INFO: checking Analysis
176 INFO: Building Analysis because Analysis-00.toc is non existent
176 INFO: Initializing module dependency graph...
177 INFO: Caching module graph hooks...
182 INFO: Analyzing base_library.zip ...
2227 INFO: Caching module dependency graph...
2314 INFO: running Analysis Analysis-00.toc
2336 INFO: Analyzing /home/feacluster/.local/lib/python3.6/site-packages/ccx2paraview/__init__.py
3719 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from '/home/feacluster/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-urllib3.packages.six.moves.py'.
4707 INFO: Processing pre-safe import module hook six.moves from '/home/feacluster/.local/lib/python3.6/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-six.moves.py'.
5158 INFO: Processing module hooks...
5158 INFO: Loading module hook 'hook-lxml.py' from '/home/feacluster/.local/lib/python3.6/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks'...
5412 INFO: Loading module hook 'hook-lxml.etree.py' from '/home/feacluster/.local/lib/python3.6/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks'...
5412 INFO: Loading module hook 'hook-lxml.isoschematron.py' from '/home/feacluster/.local/lib/python3.6/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks'...
5415 INFO: Loading module hook 'hook-lxml.objectify.py' from '/home/feacluster/.local/lib/python3.6/site-packages/_pyinstaller_hooks_contrib/hooks/stdhooks'...
5415 INFO: Loading module hook 'hook-difflib.py' from '/home/feacluster/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
5417 INFO: Loading module hook 'hook-encodings.py' from '/home/feacluster/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
5456 INFO: Loading module hook 'hook-heapq.py' from '/home/feacluster/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
5458 INFO: Loading module hook 'hook-multiprocessing.util.py' from '/home/feacluster/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
5458 INFO: Import to be excluded not found: 'test'
5459 INFO: Loading module hook 'hook-pickle.py' from '/home/feacluster/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
5460 INFO: Loading module hook 'hook-sqlite3.py' from '/home/feacluster/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
5494 INFO: Loading module hook 'hook-xml.dom.domreg.py' from '/home/feacluster/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
5494 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from '/home/feacluster/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
5494 INFO: Loading module hook 'hook-xml.py' from '/home/feacluster/.local/lib/python3.6/site-packages/PyInstaller/hooks'...
5505 INFO: Looking for ctypes DLLs
5506 INFO: Analyzing run-time hooks ...
5509 INFO: Including run-time hook '/home/feacluster/.local/lib/python3.6/site-packages/PyInstaller/hooks/rthooks/pyi_rth_pkgutil.py'
5511 INFO: Including run-time hook '/home/feacluster/.local/lib/python3.6/site-packages/PyInstaller/hooks/rthooks/pyi_rth_inspect.py'
5512 INFO: Including run-time hook '/home/feacluster/.local/lib/python3.6/site-packages/PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py'
5519 INFO: Looking for dynamic libraries
5823 INFO: Looking for eggs
5823 INFO: Using Python library /lib64/libpython3.6m.so.1.0
5828 INFO: Warnings written to /home/feacluster/.local/lib/python3.6/site-packages/ccx2paraview/build/__init__/warn-__init__.txt
5856 INFO: Graph cross-reference written to /home/feacluster/.local/lib/python3.6/site-packages/ccx2paraview/build/__init__/xref-__init__.html
5864 INFO: checking PYZ
5864 INFO: Building PYZ because PYZ-00.toc is non existent
5864 INFO: Building PYZ (ZlibArchive) /home/feacluster/.local/lib/python3.6/site-packages/ccx2paraview/build/__init__/PYZ-00.pyz
6344 INFO: Building PYZ (ZlibArchive) /home/feacluster/.local/lib/python3.6/site-packages/ccx2paraview/build/__init__/PYZ-00.pyz completed successfully.
6349 INFO: checking PKG
6350 INFO: Building PKG because PKG-00.toc is non existent
6350 INFO: Building PKG (CArchive) __init__.pkg
6364 INFO: Building PKG (CArchive) __init__.pkg completed successfully.
6365 INFO: Bootloader /home/feacluster/.local/lib/python3.6/site-packages/PyInstaller/bootloader/Linux-64bit-intel/run
6365 INFO: checking EXE
6365 INFO: Building EXE because EXE-00.toc is non existent
6365 INFO: Building EXE from EXE-00.toc
6365 INFO: Copying bootloader EXE to /home/feacluster/.local/lib/python3.6/site-packages/ccx2paraview/build/__init__/__init__
6365 INFO: Appending PKG archive to ELF section in EXE
6378 INFO: Building EXE from EXE-00.toc completed successfully.
6379 INFO: checking COLLECT
6379 INFO: Building COLLECT because COLLECT-00.toc is non existent
6379 INFO: Building COLLECT COLLECT-00.toc
6407 INFO: Building COLLECT COLLECT-00.toc completed successfully.
[feacluster@micro ccx2paraview]$ ls
build     dist        __init__.py    __pycache__  writer.py
clean.py  frd2vtk.py  __init__.spec  reader.py
[feacluster@micro ccx2paraview]$ cd dist
[feacluster@micro dist]$ ll
total 4
drwxrwxr-x. 5 feacluster feacluster 4096 Dec  5 20:06 __init__
[feacluster@micro dist]$ cd *
[feacluster@micro __init__]$ ls
base_library.zip  libexslt.so.0         libreadline.so.7  libz.so.1
__init__          libffi.so.6           libsqlite3.so.0   lxml
libbz2.so.1       libgcrypt.so.20       libssl.so.1.1     psutil
libcrypto.so.1.1  libgpg-error.so.0     libtinfo.so.6
lib-dynload       liblzma.so.5          libxml2.so.2
libexpat.so.1     libpython3.6m.so.1.0  libxslt.so.1
[feacluster@micro __init__]$ ./__init__
Traceback (most recent call last):
  File "ccx2paraview/__init__.py", line 21, in <module>
ModuleNotFoundError: No module named 'writer'
imirzov commented 2 years ago

Hi,

Please, have a look here: https://github.com/calculix/ccx2paraview#for-developers

I used PyInstaller for older Python. For newer one you'd better use nuitka.

Also command for PyInstaller was: pyinstaller init.py --onefile

Hope it will help.

feacluster commented 2 years ago

Thanks, yes I did try --onefile and got the same error:

[feacluster@micro ccx2paraview]$ pwd
/home/feacluster/.local/lib/python3.6/site-packages/ccx2paraview
[feacluster@micro ccx2paraview]$ cd dist
[feacluster@micro dist]$ ./__init__
Traceback (most recent call last):
  File "ccx2paraview/__init__.py", line 21, in <module>
ModuleNotFoundError: No module named 'writer'
[3202] Failed to execute script '__init__' due to unhandled exception!

I am using Python 3.6.8 . Perhaps something to do with how/where I am running pyinstaller. It is not that important. Was just curious to see if it would speedup ccx2paraview execution time...

feacluster commented 2 years ago

Think I figured it out . Had to add the directory of the init.py file to pyinstaller:

pyinstaller --paths=/home/feacluster/.local/lib/python3.6/site-packages/ccx2paraview __init__.py --onedir

It is strange that pyinstaller does not automatically include the path where init.py is located in..