简体   繁体   中英

Workaround for “ImportError: DLL load failed while importing mariadb: The specified module could not be found.”

After installing MariaDB Connector/Python on Windows 64-bit with Python 3.8.3 I am getting the following error in import mariadb :

ImportError: DLL load failed while importing mariadb: The specified module could not be found.

Apparently this is a known issue . Could you, please, help me to find a workaround until the issue is fixed?

Listing of venv\app_name\Lib\site-packages\mariadb-0.9.58.dist-info produces the following results:

2020-05-25  16:41                 4 INSTALLER
2020-05-25  16:41            27,030 LICENSE
2020-05-25  16:41             2,625 METADATA
2020-05-25  16:41               572 RECORD
2020-05-25  16:41                 8 top_level.txt
2020-05-25  16:41               105 WHEEL
               6 File(s)         30,344 bytes

Apparently it doesn't look like a lot of useful stuff because there are no Python or C/C++ modules. So perhaps the installation with pip3 install --pre mariadb has failed silently (nevertheless it reported success).

I have the following candidate solutions in mind:

  1. Use MySQL Connector/Python to connect to MariaDB. Is this a viable solution?
  2. Build MariaDB Connector/Python from sources or otherwise download a pre-built package if it's available. But how to do this?

Apparently the quickest and most reliable solution (as far as I can see) was to build MariaDB Connector/Python from sources by following the steps from wiki , specifically, having MSVS 2019 and MariaDB Connector/C installed, I did the following from within the virtual environment command line:

set MARIADB_CC_INSTALL_DIR="C:\Program Files\MariaDB\MariaDB Connector C 64-bit"
python setup.py build
python setup.py install

This bug was caused by a small typo, instead of linking statically, MariaDB Connector/C was linked dynamically, but libmariadb.dll couldn't be loaded.

There are actually 3 options:

  1. Build C/Python yourself, as Serge already pointed out in his answer.
  2. Install MariaDB Connector/C, and put the \lib and \lib\plugin directory in your path.
  3. Install MariaDB Connector/Python 0.9.59-beta, which I uploaded to pypi.org just a few minutes before.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM