I am having a problem with PyInstaller including any imported custom modules. I have a main.py that calls a method
from Printer.function import Repeat
def main():
name = input("Your Name: ")
Repeat(3,name)
input("Press enter to exit")
main()
Through VS Code, everything is working.
However using pyInstaller, when I run the exe file it throws an error that the module 'function' is not found. I am running this command
pyinstaller.exe -p K:\HelloWorldEXE\Printer K:\HelloWorldEXE\main.py --onefile
Can any one shed some light on this? I don't know how to use hidden-imports or hooks to make it work
Thanks.
Two possible solutions
1.
As @Legorooj mentioned try running it from the directory where the script is,e.g.
K:\HelloWorldEXE> pyinstaller main.py --onefile
2.
By default, python only searches current directory. So if you want you can also append the path a bit.
In your script, set the path to your package:
import sys
sys.path.append('C:\PathTo\project\package1')
import module1
That should fix the issue you were having.