Reputation: 27
I am new to programming. I have made a python script. It runs without errors in pycharm. Using pyinstaller i tried to make an exe. When i run the exe in build or dist folder or even through command prompt, it gives me the error 'Failed to execute Script Main'
I am attaching the warnings file link:
https://drive.google.com/open?id=1cDQ2KGId0B8K9Qi1bWPIhL55hQO0dM-z
Kindly help!
Upvotes: 1
Views: 12650
Reputation: 725
I know I write this 10 months after but i run into the same problem and i know the solution. so, maybe some people who have the same problem could get help.
If your script has any additional files such as db,csv,png etc. you should add this files same directory. in this way you could solve the problem i guess. at least my problem was solved this way.
Upvotes: 1
Reputation: 1908
There is one pip script for each virtual environment. So when you install a python module it get installed into the projectname\venv\Lib\site-packages directory.
When you run pyinstaller from terminal to make the executable, pyinstaller checks for dependencies in Sys.path . But that path does not include the projectname\venv\Lib\site-packages directory. Therefore pyinstaller cannot find those particular dependencies. In such cases it gives you warnings.Those warning can be found in 'warnname.txt' near your executable file.
How to Configure pycharm to run pyinstaller
Script name: path to your python script
working path: Project location
Leave interpreter options as it is in the image.
Run pyinstaller. You can find your .exe in dist directory.
If the "Module not found" error still persists. You can add a hidden import hook and specify the names of the missing modules.Navigate to Project Path\venv\Lib\site-packages\PyInstaller\hooks and create a new "hook-pandas.py"(hook-modulename.py) script and make a list of hidden import modules like this:
hiddenimports = ['pandas._libs.tslibs.np_datetime','pandas._libs.tslibs.nattype','pandas._libs.skiplist']
Upvotes: 3