簡體   English   中英

“ImportError: DLL load failed while importing mariadb: The specified module could not be found”的解決方法。

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

在使用 Python 3.8.3 在 Windows 64 位上安裝 MariaDB 連接器/Python 后,我在import mariadb時收到以下錯誤

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

顯然這是一個已知問題 請您幫我找到解決方法,直到問題得到解決?

venv\app_name\Lib\site-packages\mariadb-0.9.58.dist-info產生以下結果:

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

顯然它看起來不是很多有用的東西,因為沒有 Python 或 C/C++ 模塊。 所以也許用pip3 install --pre mariadb失敗了(盡管它報告成功)。

我想到了以下候選解決方案:

  1. 使用 MySQL 連接器/Python 連接到 MariaDB。 這是一個可行的解決方案嗎?
  2. 從源代碼構建 MariaDB 連接器/Python 或以其他方式下載預構建的 package(如果可用)。 但是如何做到這一點?

顯然,最快和最可靠的解決方案(據我所知)是按照 wiki 中的步驟從源代碼構建 MariaDB Connector/Python,特別是安裝了 MSVS 2019 和 MariaDB Connector/C,我在虛擬環境命令行:

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

這個錯誤是由一個小錯字引起的,而不是靜態鏈接,MariaDB Connector/C 是動態鏈接的,但 libmariadb.dll 無法加載。

實際上有3個選項:

  1. 正如 Serge 在他的回答中已經指出的那樣,自己構建 C/Python。
  2. 安裝 MariaDB Connector/C,並將 \lib 和 \lib\plugin 目錄放在你的路徑中。
  3. 安裝 MariaDB Connector/Python 0.9.59-beta,幾分鍾前我上傳到 pypi.org。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM