0

I am working on a GUI application and I wish to convert my python code to an executable file.

The program works without any issues when run as a .py file. However, when I try to convert it into .exe with pyinstaller --onedir, it compiles my program without any errors, but when I double-click the .exe, it doesn't work. The console opens momentarily and closes immediately. There are no errors but also no GUI window.

The same issue persists even if I use auto-py-to-exe instead. I am stuck here and would appreciate any help with this. Thank you.

Edit: Instead of double-clicking the .exe, I tried running it from cmd, the error traces back till markdown folder in site-packages of my virtual environment.

    exec(bytecode, module.__dict__)
  File "lib\site-packages\markdown\htmlparser.py", line 30, in <module>
  File "<frozen importlib._bootstrap>", line 580, in module_from_spec
AttributeError: 'NoneType' object has no attribute 'loader'
[8788] Failed to execute script app

This part in the htmlparser.py file reads as follows:

spec = importlib.util.find_spec('html.parser')
htmlparser = importlib.util.module_from_spec(spec)
spec.loader.exec_module(htmlparser)
sys.modules['htmlparser'] = htmlparser

Note: I have (Python==3.7.9, Pyinstaller==3.6, auto-py-to-exe==2.7.8). I found a similar question here but it does not have any satisfactory responses.

videzign
  • 11
  • 3
  • Try running the exe from an existing command prompt rather than double clicking the exe. You should then be able to see the error messages and then update your question with those if it isn't clear how to fix it. – Mark Adamson Nov 02 '20 at 19:39
  • What libraries are you using and what does your file directory look like for the program? – David sherriff Nov 02 '20 at 19:42
  • @MarkAdamson I have edited the question with the error I found on running .exe from cmd. – videzign Nov 02 '20 at 20:34
  • @Davidsherriff I am primarily using pandas, numpy, datetime, PyQt5, tabulate etc. If I understand your question correctly about the file directory, there are 7 subfolders in my file directory, containing different filetypes I use in the program (images, JSON, xlsx etc.). – videzign Nov 02 '20 at 20:54
  • @videzign is the main script in the root folder? Maybe an issue calling the other scripts from the main script when producing exe – David sherriff Nov 03 '20 at 13:03
  • @Davidsherriff yes the main script is in root folder. Trying to figure out if any issue calling other scripts from the main. – videzign Nov 03 '20 at 13:27

1 Answers1

0

Run pylint on the script, and all imported modules.

I just ran into the same issue, and it was because I made a change to an imported module that broke the module (eg. Syntax error). Instead of reporting an import error, it just says "Failed to execute script app". Technically correct, but misleading.