Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Problem in running an executable file in Python

I have a simple Python code (3.12 version). It just computes the sum of the ASCII’s of a name entered by the user:

import sys
args = sys.argv
name=args[1]
print(f"Hello, {name}!")
print("Here is some intelligence that will return a number you will NEVER understand how it is 
 computed :-D \n")
name = name.lower() 
ascii_sum = 0

for char in name:
    if char.isalpha():
        ascii_value = ord(char) 
        ascii_sum += ascii_value

print(ascii_sum)

that I have transformed in an executable called dummy_fct.exe. Because for some reason I need to be able to call a (Python) executable from an ipynb notebook.

Now, I am trying to call this executable from a new notebook:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

import subprocess
import sys
name = input("Quel est ton nom ? ")
subprocess.run(["dummy_fct.exe", name], capture_output=True, text=True)

But got the following error:

CompletedProcess(args=[‘dummy_fct.exe’, ‘PDH’], returncode=1, stdout=”, stderr='[4004] Module object for pyimod02_importers is NULL!\nTraceback (most recent call last):\n File "PyInstaller\loader\pyimod02_importers.py", line 22, in \n File "pathlib.py", line 14, in \n File "urllib\parse.py", line 40, in \nModuleNotFoundError: No module named ‘ipaddress’\nTraceback (most recent call last):\n File "PyInstaller\loader\pyiboot01_bootstrap.py", line 17, in \nModuleNotFoundError: No module named ‘pyimod02_importers’\n[4004] Failed to execute script ‘pyiboot01_bootstrap’ due to unhandled exception!\n’)

I do say that I do not understand at all this error message… Can you help me ?

EDIT: The executable was created running these two commands:

jupyter nbconvert --to script dummy_fct.ipynb
pyinstaller --onefile dummy_fct.py

>Solution :

This seems to be bug with pyinstaller(affecting Python >=3.11.4) which is reported here and it has fixed in v5.12. So the solution is to upgrade the pyinstaller version to >=5.12.

pip install "pyinstaller>=5.12"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading