问题
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