PyInstaller can't understand my package imports

26 views
Skip to first unread message

Graham Hill

unread,
Apr 20, 2020, 3:38:33 AM4/20/20
to PyInstaller
I'm using PyInstaller on Windows on a project structured as a package, like this:

myproject/
myproject/
__init__.py 
subpackage_a/
__init__.py 
module_a.py
subpackage_b/
__init__.py
module_b.py
cli.py

The entry point is cli.py, which starts like this:

import logging
import click

from myproject.subpackage_a import module_a
from myproject.subpackage_b import module_b

I'm running this PyInstaller command:

pyinstaller cli.py -y --clean

It fails to find the modules in the pyproject package, reporting the following in the warn-cli.txt:

missing module named 'myproject.subpackage_a' - imported by C:\LocalProjects\myproject\cli.py (top-level)
missing module named 'myproject.subpackage_b' - imported by C:\LocalProjects\myproject\cli.py (top-level)


I've already tried adding --paths ./myproject to the PyInstaller command, as well as putting the cli.py file inside the package and adjusting the PyInstaller command appropriately, neither of which made any difference to the result. 

This seems like really basic functionality, so I figure I'm missing something simple but non-obvious. Any help would be appreciated.

Graham Hill

unread,
Apr 20, 2020, 3:59:36 AM4/20/20
to PyInstaller
Turns out I had a stray __init__.py at the top level of the project. As soon as I removed that file, the build worked perfectly.
Reply all
Reply to author
Forward
0 new messages