Python: ImportError no module named mysql.connector

本小妞迷上赌 提交于 2020-01-30 08:11:07

问题


I just created an exe from python script and when I tried to run it, it did not show up.

Then, I tried to run it from cmd and I got ImportError below:

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

How to solve this? I have installed mysql.connector using both pip install and conda install.


回答1:


According to the pyinstaller docs here, pyinstaller is not finding the python module, so explicitly include it like so:

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


来源:https://stackoverflow.com/questions/44015654/python-importerror-no-module-named-mysql-connector

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!