I'm trying to make an .exe from a python script, using pyinstaller, but having issues when trying to make as onefile.
When running just below, everything works fine
pyinstaller myscript.py
When trying to make onefile, it cannot find packages.
pyinstaller --onefile myscript.py
When running the resulting .exe, I see errors such as: No module named 'mylib'
Trying to explicitly include doesn't work either.
pyinstaller --onefile --hiden-import=mylib myscript.py
You can reproduce using the example below:
My file structure is exactly this:
__init__.py
myscript.py
Compile.bat
.\mylib
--| __init__.py
--| mypackage.py
myscript.py:
from mylib.mypackage import myfunc
x = myfunc()
mypackage.py:
def myfunc():
input('Successfully Run')
Compile.bat:
cd /D "%~dp0"
pyinstaller --onefile myscript.py
set library="mylib"
set libdest="dist\mylib"
robocopy "%library%" "%libdest%" /E
All init files are empty.
After running the batch file, the dist folder structure is:
.\dist
--| myscript.exe
--| .\mylib
------| __init__.py
------| mypackage.py
Any suggestions or feedback is appreciated.