Frage

I have a Pyinstaller set up (automated spec generation and packaging) that's currently working on ubuntu, windows and MacOS. I'm now trying to make it work in raspberry pi (with raspbian installed) for what I've had to build the bootloaders as stated in documentation

The app I'm bundling consists on an entry point that imports needed modules (the rest of the app and external dependencies) and calls main loop.

Basic structure is something like this:

+-- main.py
+-+ my_module
  |--+ other.py
  |--+ more_files.py

main.py imports external dependencies and my_module Package is correctly generated but when I exec generated binary it throws an error:

Traceback (most recent call last):
  File "<string>", line 43, in <module>
NameError: name 'my_module' is not defined

But if I go to pyinstaller dist/my_app directory I see it there and if I run a python console in there I can do:

from my_module import other
other.main()

And runs fine, so it seems that the binary is missing some PYTHON_PATH information or something.

Notes:

  • my_module import is last one in main.py, seems not to have problems importing modules retrieved from site-packages
  • Same error is thrown either if I package it with --onefile, --onedir or none
  • Same config script is generating working packages in the rest of platforms
War es hilfreich?

Lösung

I found the problem, imports in main.py where under a try. Either putting them outside the try or adding them as hidden imports in spec file solves the problem. What I don't know is I need to do that for rpi and not the rest of the platforms.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top