[英]Problems using the mariadb module for python
我目前需要創建一個 python 腳本來訪問我本地機器上的 MariaDB 數據庫。
我的名為Murphy.py
的文件包含
# file: Murphy.py
import mariadb
在與我的Murphy.py
相同的目錄中,我運行命令將我的 python 更新為 python 3
$ brew install python3
然后為我運行的 python 安裝 mariadb 模塊
$ pip3 install mariadb
它返回消息
Collecting mariadb
Downloading mariadb-1.0.6.tar.gz (67 kB)
|████████████████████████████████| 67 kB 6.4 MB/s
Building wheels for collected packages: mariadb
Building wheel for mariadb (setup.py) ... done
Created wheel for mariadb: filename=mariadb-1.0.6-cp39-cp39-macosx_11_0_x86_64.whl size=59180 sha256=17d128175eab51d0edc8387999d5eb7100f80787f95f595561a061c540f364fd
Stored in directory: /Users/owenmurphy/Library/Caches/pip/wheels/d7/4a/4f/05b62af6cd28564b274014392f29113b6fedfeaaaaab21441a
Successfully built mariadb
Installing collected packages: mariadb
Successfully installed mariadb-1.0.6
然后我嘗試使用命令運行文件
$ python Murphy.py
返回錯誤
Traceback (most recent call last):
File "Murphy.py", line 4, in <module>
import mariadb
ImportError: No module named mariadb
我不確定我做錯了什么。 任何幫助都很棒!
注意:我正在運行 macOS Bug Sur 版本 11.2.1
如果需要更多信息,請告訴我!
正如 pip3 中的數字所示,pip3 為 Python 3 安裝模塊,而您的標准 python 解釋器是 python 2.7(即 EOL)。
而不是 python 使用 python3 加載 MariaDB 連接器/Python 模塊。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.