Python:ImportError没有名为mysql.connector的模块

时间:2017-05-17 04:33:03

标签: python python-2.7 mysql-python importerror mysql-connector-python

我刚从exe脚本创建了python,当我尝试运行它时,它没有显示出来。

然后,我尝试从cmd运行它,我得到了ImportError

Traceback (most recent call last):
  File "tkintertest2.py", line 17, in <module>
  File "Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 
389, in load_module
  File "MySQL.py", line 1, in <module>
ImportError: No module named mysql.connector
Failed to execute script tkintertest2

如何解决这个问题?我使用mysql.connector安装和pip安装安装了conda

1 个答案:

答案 0 :(得分:2)

根据pyinstaller文档here,pyinstaller没有找到python模块,所以明确地包含它如下:

pyinstaller --hidden-import mysql.connector myscript.py