close

[Solved] Import Error: paho.mqtt.client not found

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Import Error: paho.mqtt.client not found in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Import Error: paho.mqtt.client not found Error Occurs?

Today I get the following error Import Error: paho.mqtt.client not found in python.

How To Solve Import Error: paho.mqtt.client not found Error ?

  1. How To Solve Import Error: paho.mqtt.client not found Error ?

    To Solve Import Error: paho.mqtt.client not found Error You have installed Python3 but for some reason the interpreter defaults to version 2.7 in Linux.

  2. Import Error: paho.mqtt.client not found

    To Solve Import Error: paho.mqtt.client not found Error You have installed Python3 but for some reason the interpreter defaults to version 2.7 in Linux.

Solution 1


I think I have found the problem,

You have installed Python3 but for some reason the interpreter defaults to version 2.7 in Linux.

Try using pip3 install paho-mqtt python-etcd instead.

Or if it does not work, you can literally copy and paste the paho folder from your Python2.7 site-packages folder to your Python3 site-packages folder. I have just verified paho-mqtt 1.2 for Python2 is exactly the same as paho-mqtt 1.2 for Python3 using a Meld diff tool. Please note, when you directly copy and paste pip list will not display the package you copied.

site-packages are usually inside your system lib folder. It depends upon how Python is installed. In my case everything is inside $HOME/.pyenv folder.

Remember Python2 has it’s own site-packages folder and Python3 has it’s own site-packages folder where Python searches for the packages. Sometimes if you are using a Debian based Linux distro please make sure to check inside the dist-packages folder as well to see if you can find the package you are looking for.

Solution 2

You can try install Paho lib:

git clone https://github.com/eclipse/paho.mqtt.python

Once you have the code, it can be installed from your repository as well:

cd paho.mqtt.python
python setup.py install

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read