I have a test example structured as:
.
├─ mypkg
│ ├─ __init__.py
│ └─ mymod.py
├─ mycli.py
where mycli.py is
import mypkg.mymod
mypkg.mymod.myfunc()
mymod.py is
def myfunc():
print("Hello, World")
and that all works perfectly.
A slightly different mycli.py,
import mypkg
if __name__ == "__main__":
mypkg.mymod.myfunc()
bundles to an executable but fails to execute with the following Traceback:
Traceback (most recent call last):
File "mycli.py", line 6, in <module>
mypkg.mymod.myfunc()
AttributeError: module 'mypkg' has no attribute 'mymod'
[83952] Failed to execute script mycli
(the same failure as you get with "python mycli.py").
My understanding is that using --hidden-import=mypkg.mymod has the effect
of inserting "import mypkg.mymod" into the source code before running,
which should make it equivalent to the first script (that worked), but the
bundled executable still fails.
warn-mycli.txt lists a few missing modules but nothing related to mypkg.
With --hidden-import=mypkg.mymod, mypkg.mymod appears in the
build/mycli/xref-mycli.html file, possibly suggesting that it was
recognised, but the bundled executable still fails.
If I run with "--debug all" I get a dist/mycli/mypkg/mymod.pyc file, also
suggesting it was finding and compiling the module correctly, but the
bundled executable still fails.
I've also tried with an equivalent hook:
hiddenimports = ["mypkg.mymod"]
which runs (as confirmed by adding a print statement), but the bundled
executable still fails.
I also have the same problem when calling "python -m PyInstaller ..."
rather than just "pyinstaller ..."
I'm using Python 3.5.10 & PyInstaller 4.0 on Ubuntu 20.04 under VirtualBox
6.1, and have the same problem with and without using a virtualenv (also
trying with Python 3.8).
Can anyone spot where I'm going wrong, please?
Thanks.
--
You received this message because you are subscribed to the Google Groups
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyinstaller/0eeb64b0-e295-4b06-bf32-9f7b0cec5f90n%40googlegroups.com.