the_pied_shadow
the_pied_shadow

Reputation: 396

How do I handle custom modules when creating an exe with PyInstaller?

Using PyInstaller I created a executable from a python script as follows:

pyinstaller --onefile pythonScriptName.py

However, when I run the executable I get an error ImportError: No module named 'MyModule'. 'MyModule' is a placeholder name for a custom module I use in the script. So I'm assuming that PyInstaller didn't package up the custom modules. Is there some way to get it to do that?

Upvotes: 3

Views: 7045

Answers (1)

nirlevywm
nirlevywm

Reputation: 181

I found the --collect-submodules flag to be helpful when getting an import module error. I just specify the folder name under which all my modules are and pyinstaller collects all the imports automatically. something like this:

pyinstaller --collect-submodules <folder-name> 

Upvotes: 1

Related Questions