Skip to content
Advertisement

Exception when trying to import python mysql connector on raspberry pi

I’m trying to use the python MySQL connector on my Raspberry PI but I’m getting this error as soon as I add the import statement to the script.

JavaScript

The same happens when I try to import only parts of it.

JavaScript

The error:

JavaScript

I used PIP to install the connector …

JavaScript

… and also already tried to force-reinstall it:

JavaScript

Advertisement

Answer

This problem appears to be caused by using the default Raspbian install of Python, which is Python 2.7.

Use Python 3 instead. It is also installed on Raspbian. Use python3 and pip3 in place of python and pip.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement