加载Python dll / LoadLibrary时出错:找不到指定的模块

时间:2017-11-14 15:17:33

标签: python pyinstaller

我是编程新手。我在python中编写了一个小程序,并使用pyinstaller将其转换为exe文件。现在当我尝试打开exe文件时出现黑屏并立即关闭。我能够获得一个屏幕截图。Screen Shot 我看到了一个解决方案,比如在代码末尾添加input()但它也不起作用。我的代码:

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 could'nt find the number. The number is " + str(number))

3 个答案:

答案 0 :(得分:3)

这对我有用:

  

遇到相同的问题,但随后意识到我无意间尝试执行build文件夹而不是dist文件夹中的文件。

     

看起来您可能在追溯中犯了同样的错误,因此请查看在dist中使用可执行文件是否不能为您解决

(来源:https://stackoverflow.com/a/54119819/4607733

答案 1 :(得分:0)

屏幕截图中显示的问题是无法找到Python库。因此,pyinstaller中的某些配置是错误的。你确定python36.dll在那个文件夹中吗?检查python36.dll所在的位置(通常位于python安装所在的文件夹中,并且可以找到python.exe)。也许您需要将此路径添加到Windows路径配置中?

请检查以下两个答案,看看您的pyinstaller是否配置正确:

PyInstaller not working on simple HelloWorld Program

Error loading python27.dll error for pyinstaller

对于Python 3.6

,情况应该类似

答案 2 :(得分:0)

那是因为你创建了依赖整个文件夹的exe文件。这就是为什么它只能在 dist 文件夹中工作。

简单的解决方案:

使用 pyinstaller 和 onefile 选项创建 exe 文件。 它只会在 dist 文件夹中创建 exe 文件,并且可以在我们想要的任何地方执行。

在 cmd 中使用 bellow 命令。

<块引用> <块引用>

pyinstaller --onefile file_name.py

相关问题