LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   python code error: ModuleNotFoundError: No module named 'mariadb' (https://www.linuxquestions.org/questions/linux-software-2/python-code-error-modulenotfounderror-no-module-named-mariadb-4175736585/)

shams 04-30-2024 03:14 PM

python code error: ModuleNotFoundError: No module named 'mariadb'
 
Hi,
I successfully installed the mariadb python module to the python virtual enviroment '/home/user/venv' with the command '/home/user/venv/bin/pip install mariadb' in arch linux, and activated the venv with command '/home/user/venv/bin/activate' now when run the python code:
Code:

import mariadb
import sys
import configparser

The code cannot import the mariadb module from '/home/user/venv', and print this error:
Code:

ModuleNotFoundError: No module named 'mariadb'

RandomTroll 05-01-2024 12:13 AM

Did the install of the python module's libraries go into lib instead of lib64? I had the same error with solaar recently. I have a 64-bit system. It put its python libraries in /lib/python3.11 but python was looking for them in /usr/lib64/python3.11 https://www.linuxquestions.org/quest...ib-4175736432/

pan64 05-01-2024 02:18 AM

I think you need to activate that venv before installing anything into it.

sundialsvcs 05-01-2024 07:18 AM

Quote:

Originally Posted by pan64 (Post 6499212)
I think you need to activate that venv before installing anything into it.

I also believe this to be the case. First activate the venv, then use the pip-install command. (But first: after activating the venv, "does it work now?")

shams 05-01-2024 05:18 PM

Thanks for replies, it is lib64 as well there, i activated the venv first then installed the mariadb but still get the above error.

pan64 05-02-2024 02:04 AM

Quote:

Originally Posted by shams (Post 6499366)
i activated the venv first then installed the mariadb but still get the above error.

Do you know it is nonsense? This is the official way to install it. I'm pretty sure you made something differently, or you made a mistake or who knows? But saying "still get the above error" contains no usable information, we can only say it is nonsense. Or probably the error is in line 27.
Would be nice to show us the details. Exactly what did you execute, what's happened.


All times are GMT -5. The time now is 08:33 AM.