ImportError: No module named parse

Error:

When trying to import mysql connector, below error thrown.

Traceback (most recent call last):
  File "kafka_produce_patient_vitals.py", line 7, in <module>
    import mysql.connector
  File "/usr/lib/python2.7/site-packages/mysql/connector/__init__.py", line 53, in <module>
    from .connection import MySQLConnection
  File "/usr/lib/python2.7/site-packages/mysql/connector/connection.py", line 39, in <module>
    from .authentication import get_auth_plugin
  File "/usr/lib/python2.7/site-packages/mysql/connector/authentication.py", line 37, in <module>
    from urllib.parse import quote
ImportError: No module named parse

Solution:

There are two python versions installed in your system and you try to conflict both the version while import of package

Remove the python binary of old version

sudo rm /usr/bin/python

Symbolic link the new version of python

 sudo ln -s /usr/bin/python3 /usr/bin/python

Check the version

python --version

Import the package

import mysql.connector

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s