I am only the beginner. I want to use the MySql database in my Python program on Windows 11 with the python version 3.10.
I have to use the command ‘import connect’, but I do not know how to download and install the package ‘connect’ on the path 'C:\Program Files\Python' instead on the map ‘users.…\AppData\Roaming\Python.…’.
My Windows path contains:
PATH=C:\Program Files\Python\Scripts;C:\Program Files\Python;…
I’d advise to keep Python (in C:\Program Files\Python) and Python packages (in users.…\AppData\Roaming\Python.…) separate. Python (the interpreter) uses a different search path for packages than Windows (the OS) uses for programs.
I have used the command ’ by pip install mysql-connector-pythonsuccessfully. That module is apparently place in the path ‘C:\Users.…\AppData\Roaming\Python\Python310\site-packages’.
I have adapted my systempath as follows:
PATH=C:\Program Files\Python\Scripts;C:\Program Files\Python;C:\Users.…\AppData\Roaming\Python\Python310\site-packages;C:\Users.…\AppData\Roaming\Python\Python310\Scripts;C:\WINDOWS\system32;…
Then I tried to run my Python program containing the command ‘import mysql.connector’. Unfortunately I got the error: No module named ‘mysql’!?
My code ‘import mysql’ does work fine, however after my follwing codes have been processed successfully:
xxx = # i.e. empty list
xxx.append(‘C:\Program Files\Python\DLLs’)
xxx.append(‘C:\Program Files\Python\Lib’)
xxx.append(‘C:\Program Files\Python’)
xxx.append(‘C:\Program Files\Python\lib\site-packages’)
xxx.append(‘C:\Users\DeVrije\AppData\Roaming\Python\Python310\site-packages’)
sys.path = xxx.copy()
Now I wonder me how i can create ‘PYTHONPATH’, so that it will be processed automaticcaly without my previous cumbersome and unnecessary codes.
At last I wonder me why mysql does not support UTF8, because when my code ‘mydb = mysql.connector.connect(host=‘localhost’, user=’…‘, password=’…') has been processed, I got the error as follows:
<class ‘mysql.connector.errors.ProgrammingError’>: Character set ‘utf8’ unsupported
I wonder me, whether that utf8 problem cab be caused by my mysql database being set up by the phpMyAdmin or Apache web server with MariaDB (i.e. MySQL) and PHP. If so, what have I to do.