marcelotduarte / cx_Freeze

cx_Freeze creates standalone executables from Python scripts, with the same performance, is cross-platform and should work on any platform that Python itself works on.
https://marcelotduarte.github.io/cx_Freeze/
Other
1.37k stars 220 forks source link

ModuleNotFoundError: No module named 'MySQLdb' #2642

Open HyperDev724 opened 1 month ago

HyperDev724 commented 1 month ago

Prerequisite

Describe the bug When I was packaging the Flask project, the exe program encountered an error: ModuleNotFoundError: No module named 'MySQLdb' image

Desktop (please complete the following information):

Flask==1.1.2 Flask-Bcrypt==0.7.1 Flask-Cors==3.0.8 Flask-Migrate==2.5.3 Flask-Script==2.0.6 Flask-SQLAlchemy==2.4.3 mysqlclient==2.0.0 PyMySQL==1.1.1 SQLAlchemy==1.3.18

Additional context Add any other context about the problem here.

marcelotduarte commented 1 month ago

Do you get success if you run the Flask project on the command line?

Well, you are using two packages that may have the same functionality, but it seems that you are using mysqlclient. cx_Freeze detects __import__ with a string but it may not be detecting an extension, so try using --includes=MySQLdb._mysql to test. For instance: python setup.py build_exe --includes=MySQLdb._mysql

marcelotduarte commented 1 week ago

@HyperDev724 Do you get success? Can I close this issue?