Score:0

ModuleNotFoundError: No module named 'mysql'

mx flag

I need to run a python script when server start .
I add in rc.local /usr/bin/python3 /usr/bin/test.py , for this I have error
import mysql.connector as mysql
ModuleNotFoundError: No module named 'mysql'
When I removed connection to mysql , is ok
I tested : python3 /usr/sbin/test.py working good , connection to mysql is ok .
I try
sudo python3 /usr/sbin/test.py - same error -
import mysql.connector as mysql
ModuleNotFoundError: No module named 'mysql'
mysql connector installed is : pip3 install mysql-connector-python
I dont have experience with linux , I think is chmod problem , but where ....?
Solved with : sudo pip3 install mysql-connector-python

user535733 avatar
cn flag
Did you install the MySQL bindings for Python (the 'mysql module')?
Catalin Radu Nicula avatar
mx flag
If I run script from python3 /usr/sbin/test.py , is ok , connect to db , write in table .<br>If run sudo python3 /usr/sbin/test.py , I have that error
user535733 avatar
cn flag
Do not add new information in comments. Comments are not intended for conversation. [Edit your question](https://askubuntu.com/posts/1446028/edit) instead. Make your question as clear and understandable as you can, and keep improving it until you get an answer.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.