Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
joelhjalmarsson opened this issue Dec 12, 2017 · 8 comments
Closed

Comments

@joelhjalmarsson
Copy link

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
Copy link
Contributor

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

@ratal
Copy link
Owner

ratal commented Dec 12, 2017

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
Copy link
Contributor

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
Copy link
Owner

ratal commented Dec 12, 2017

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

@danielhrisca
Copy link
Contributor

import sys

from pprint import pprint

pprint(sys.path)

import mdfreader

pprint(sys.path)

@cristi-neagu
Copy link
Contributor

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
Copy link
Owner

ratal commented Dec 12, 2017

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants