'MariaDb is installed but could not be imported into python
I tried to install the Mariadb plugin for python. Therefore I downloaded the MariaDB Connector and installed it and then I installed via pip3 the mariadb. And I think it worked:
Defaulting to user installation because normal site-packages is not writeable
Collecting mariadb
Using cached mariadb-1.0.6.tar.gz (67 kB)
Installing collected packages: mariadb
Running setup.py install for mariadb ... done
Successfully installed mariadb-1.0.6
But when I want to import it:
import mariadb
I still get the message: No module 'mariadb'
Any ideas what I could to to check/fix this?
Thank you in advance.
Solution 1:[1]
Not sure if you're doing that:
When you installed mariadb via pip3 you have to use Python 3 too:
python3 your_file.py
Solution 2:[2]
pip installs mariadb to a site-packages directory. On my win10, PYTHONPATH was: C:\Users\MyName\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages
But there are two site-packages. I appended to PYTHONPATH: ;C:\Users\MyName\AppData\Local\Programs\Python\Python310\Lib\site-packages
Now python imports mariadb OK.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | jake |
Solution 2 | PeterH |