1

I am currently needing to create a python script that access my MariaDB database on my local machine.

My file named Murphy.py contains

# file: Murphy.py

import mariadb

In the same directory as my Murphy.py I run the command to update my python to python 3

$ brew install python3

Then to install mariadb module for python i run

$ pip3 install mariadb

It returns the message

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

Then I try and run the file using the command

$ python Murphy.py

Which returns the error

Traceback (most recent call last):
  File "Murphy.py", line 4, in <module>
    import mariadb
ImportError: No module named mariadb

I am not sure what I am doing wrong. Any help is great!

NOTE: I am running macOS Bug Sur Version 11.2.1

Let me know if more info is needed!

3
  • What is the output of python --version ? Commented Mar 13, 2021 at 21:37
  • @GeorgRichter it is Python 2.7.16 Commented Mar 13, 2021 at 21:53
  • Nvm, I was able to use a different module for accessing MariaDB. Commented Mar 13, 2021 at 22:08

1 Answer 1

2

As the number in pip3 indicates, pip3 installs modules for Python 3, while your standard python interpreter is python 2.7 (which is EOL).

Instead of python use python3 to load MariaDB Connector/Python module.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.