Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'MySQLdb' #2642

Open
opsboy opened this issue Oct 24, 2024 · 1 comment
Open

ModuleNotFoundError: No module named 'MySQLdb' #2642

opsboy opened this issue Oct 24, 2024 · 1 comment

Comments

@opsboy
Copy link

opsboy commented Oct 24, 2024

Prerequisite

  • Make sure no duplicated issue has already been reported. You should look for closed issues, too.
  • Make sure you are not asking us to help to solve your specific issue. GitHub issues are opened mainly for development purposes. If you want to ask someone to help to solve your problem, go to some community site like StackOverflow, etc.
  • Make sure your problem is not derived from packaging (e.g. Homebrew).

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):

  • Platform information :windows11
  • cx_Freeze version : 7.2.3
  • Python version : 3.8.7

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
Copy link
Owner

marcelotduarte commented Oct 24, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants