使用openpyxl时将python转换为exe

时间:2019-01-06 16:21:50

标签: python python-3.x pyinstaller openpyxl

将python文件转换为exe给我一个错误,找不到openpyxl。我猜想在使用pyinstaller时必须使用隐藏导入,但是由于某些原因它没有任何区别。我该如何运作?

代码:

#test.py
from openpyxl import Workbook
import datetime
wb = Workbook()
ws = wb.active
ws['A1'] = 42
ws.append([1, 2, 3])
ws['A2'] = datetime.datetime.now()
wb.save("sample.xlsx")

命令行:

pyinstaller --hidden-import = openpyxl test.py

结果:

# openpyxl not found in PYZ
Traceback (most recent call last):
  File "test.py", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked

使用:

pyinstaller 3.4
Python 3.6.3
Windows 10

0 个答案:

没有答案