-2

Im trying to make the following combination work. No luck. Anyone here can help ?

flask_sqlalchemy
mysqlclient
mysql-connector-python

Python 3.9.5 setup.cfg has above package and being installed in a venv

Error

    engine = create_engine(app.config['SQLALCHEMY_DATABASE_URI'], echo = True)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/__init__.py", line 500, in create_engine
    return strategy.create(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/strategies.py", line 87, in create
    dbapi = dialect_cls.dbapi(**dbapi_args)
  File "/usr/local/lib/python3.9/site-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 118, in dbapi
    return __import__("MySQLdb")
ModuleNotFoundError: No module named 'MySQLdb'
  • This is not 'MySQL driver not loading'. This is "No module named 'MySQLdb'". Different issue. You don't have that Python module installed. – user207421 Jun 11 '21 at 10:06

1 Answers1

0

venv had to be resourced in a shell environment. So packages installed were not in path.

Also, mysql-connector-python is not required in the above setup.

So much steps for a local isolated package installation scope.

python3 -m venv venv
. venv/bin/activate
pip install -e .

cp .env to instance/ 
flask run