PIP installs. What is going on. HELP

I am struggling with trying to work out what the hell is happening.
Raspberry Pi Zero with latest Raspberry Pi OS
I then installed Python3 using

sudo apt-get install -y python3 python3-venv python3-pip idle3

I did a check with python3 -V and get Python 3.7.3

I then installed several modules, for example mysql-connector-python

sudo pip3 install mysql-connector-python

It said “Defaulting to user installation because normal site-packages is not writeable”

Now when ever I run a python script from the crontab I keep getting

File “/home/pi/Documents/Scripts/Projects/study.py”, line 15, in
** import mysql.connector**
ModuleNotFoundError: No module named 'mysql’

I have tried adding to PATH various locations but nothing seems to work.

I presume it’s down to root access, so here is a list of paths, one as sudoand the other as user pi

pi@study:~ sudo python3 /home/pi/Documents/Scripts/paths.py /home/pi /home/pi/Documents/Scripts /usr/lib/python37.zip /usr/lib/python3.7 /usr/lib/python3.7/lib-dynload /usr/local/lib/python3.7/dist-packages /usr/lib/python3/dist-packages pi@study:~ python3 /home/pi/Documents/Scripts/paths.py

Any idea how to get python to see the mysql module etc, or even how to make the main site-package directory writing for whoever. Very confusing as I am a Linux Noob

1 Like