'pyqtgraph is installed but isn't recognized when I import it

I am trying to run this code that visualizes audio waveforms and their fourier transforms https://github.com/markjay4k/Audio-Spectrum-Analyzer-in-Python/commit/ff9caf4156b7a8c039d8beba987f93566a6aace0

It requires numpy, PyQt, and pyqtgraph. When I run it, I get an error right of the bat.

from pyqtgraph.Qt import QtGui, QtCore
ModuleNotFoundError: No module named 'pyqtgraph'

I know I installed this, because I have pyqtgraph in my site-packages folder. I used pip install pyqtgraph to install it, and if I run the command again, it confirms that the install has already been performed.

What am I doing wrong? Is there some version incompatability? Do I need to do a little dance in my PJs to get it working? I'm not sure.



Solution 1:[1]

This normally happens when you try to use a library in either a different Python version, virtual environment, or platform. I'd troubleshoot as follows:

  • Check for typos and that you are using the correct way to import the library and submodules.
  • If you have multiple Python versions, make sure you are running on the one where the library is installed.
  • If you use both pip and conda, make sure you are running the code on the correct platform.
  • If both the Python version and platform are ok, check you are working in the same virtual environment where you installed the library in question. I think this is the most probable cause.

You can find plenty of tutorials on how to check all the above. If nothing works, you can try uninstalling and reinstalling.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Enric Grau-Luque