为什么我无法从python脚本打开EXE文件?

时间:2019-08-21 23:28:31

标签: python-3.x

我正在尝试将.py脚本转换为.exe。 我正在使用pyinstaller进行安装,但是我只能打开一个包含以下内容的简单文件,例如:print(“ Hello world”)。当我在脚本中使用更多行时,无法打开它。

我认为问题在于我正在导入一些库,但我不知道在构建时是否必须将它们添加到.exe中。

这里有回溯

  File "d:\programs\python\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\matplotlib\__init__.py", line 138, in <module>
  File "d:\programs\python\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\matplotlib\cbook\__init__.py", line 31, in <module>
  File "d:\programs\python\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\numpy\__init__.py", line 150, in <module>
  File "d:\programs\python\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "site-packages\numpy\random\__init__.py", line 180, in <module>
  File "mtrand.pyx", line 1, in init numpy.random.mtrand
ModuleNotFoundError: No module named 'numpy.random.common'
[13372] Failed to execute script GraficoTorta
import matplotlib.pyplot as plt; plt.rcdefaults()
import numpy as np
import matplotlib.pyplot as plt

objects = ('Python', 'C++', 'Java', 'Perl', 'Scala', 'Lisp')
y_pos = np.arange(len(objects))
performance = [10,8,6,4,2,1]

plt.bar(y_pos, performance, align='center', alpha=0.5)
plt.xticks(y_pos, objects)
plt.ylabel('Usage')
plt.title('Programming language usage')

plt.show()

0 个答案:

没有答案