ratal / mdfreader

Read Measurement Data Format (MDF) versions 3.x and 4.x file formats in python
Other
169 stars 74 forks source link

PyInstaller: ModuleNotFoundError: No module named 'mdf3reader' #120

Closed joelhjalmarsson closed 6 years ago

joelhjalmarsson commented 6 years ago

I am trying to package my application with pyinstaller. But when executing the .exe file I get the following errors:

Traceback (most recent call last): File "site-packages\mdfreader__init.py", line 28, in File "c:\python\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.dict__) File "site-packages\mdfreader\mdfreader.py", line 48, in ModuleNotFoundError: No module named 'mdf3reader'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "drivers_notes.py", line 8, in from mdfreader import mdf File "c:\python\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.dict) File "site-packages\mdfreader__init__.py", line 30, in ImportError: cannot import name 'mdfinfo' [5568] Failed to execute script drivers_notes

I have been trying via the pyinstaller support pages to find a way to solve this but I am just too much of a newbie when it comes to python, modules and dependencies. Giving it one last try here in case anyone else has any experience with mdfreader and pyinstaller.

danielhrisca commented 6 years ago

mdfreader has an obfuscated import system. Perhaps pyinstaller would succed if #91 would be implemented.

ratal commented 6 years ago

Intention was not to obfuscate import system but improve robustness of import process and support people having issues with it by introducing absolute path import. But this is not recommended way of doing indeed, which might cause the issue you are facing with pyinstaller. reading this, it could be the sys.path modification the problem. I will try again switching to relative import but in the mean time, I guess you could have a look at the spec files mentionned in the link ?

cristi-neagu commented 6 years ago

If absolute path imports are needed for command line functionality, maybe it would be better to add a specific command line frontend? Something for the future.

ratal commented 6 years ago

Can you detail about this command line frontend ? Do you mean what is at the end of mdfreader.py ?

danielhrisca commented 6 years ago
import sys

from pprint import pprint

pprint(sys.path)

import mdfreader

pprint(sys.path)
cristi-neagu commented 6 years ago

Can you detail about this command line frontend ?

I thought that the sys.path appends were due to some issues with calling the module from the command line. Maybe i misunderstood.

ratal commented 6 years ago

Absolute path is rather coming from #41 Let's call it youth mistake. You can check last commit, switched to relative path, seems to be working, more clean. Does it work better joelhjalmarsson ?

joelhjalmarsson commented 6 years ago

Hi. Yes it seems to be working better now. Thanks!