Error Loading Python Dll/ Loadlibrary: the Specified Module Could Not Be Found

I am new at programming. I wrote a small program in python and converted it to .exe file with pyinstaller. Now when i try to open the .exe file a black screen appears and closes immediately. I was able to get a screenshot:

I saw a solution like adding input() at the end of the code but it didn't work either. My code:

import random

print("Hello, what is your name?")
name = str(input())
print("Well, " + name + ", I think of a number between 1 and 1000. Can you guess this number in 10 chances?")
number = random.randint(1, 1001)

for guessTaken in range(1, 11):
  print("Take a guess")
  guess = int(input())
  if guess > number:
    print("The number you think is too high")
  elif guess < number:
    print("The number you think is too low")
  else:
    break

if guess == number:
  print("OK, " + name + ", you guessed the number in " + str(guessTaken) + " guesses")
else:
  print("Unfortunatelly, you couldn't find the number. The number is " + str(number))

3 Answers

This worked for me:

Had the same issue but then realized that I was inadvertently trying to execute the file in the build folder instead of the dist folder.

Looks like you might be making the same mistake from your traceback so see if using the executable in dist doesn't fix it for you

(Source: )

3

The problem seen in the screenshot is that the Python Library cannot be found. So some configuration in your pyinstaller is wrong. Are you sure that python36.dll is in that folder? Check where your python36.dll is located (normally in the same folder where your python installation is located and your python.exe can be found). Maybe you need to add this path to your Windows Path Configuration?

Please check the following two answers to see if your pyinstaller is configured correctly:

PyInstaller not working on simple HelloWorld Program

Error loading python27.dll error for pyinstaller

The situation should be similar for you with Python 3.6

3

It's because you have created the exe file that depends on the entire folder. That's why it is working only in the dist folder.

Simple Solution:

Create the exe file using pyinstaller with onefile option. It will only creates the exe file in the dist folder and can execute anywhere we want.

use the bellow command in cmd.

pyinstaller --onefile file_name.py

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest