pythonpython-3.xpippydot

Why does it keep saying ImportError: No module named pydot when I have already installed the module through pip?


I used command pip install pydotto install module pydot but whenever I try to run a certain file through terminal it says the following error.

Traceback (most recent call last):
  File "src/parser.py", line 3, in <module>
    import pydot
ImportError: No module named pydot

I have done endless checking to make sure it was properly installed. I did check it in the python folder and it is there, indeed.

Does anyone know what am I missing? Is there something wrong with how it was installed?

I am using a macOS.

Thank you very much!


Solution

  • First, check where the module is installed (type the following in the console):

    pip show numpy
    

    This returns the following for me (Macbook):

    Name: numpy
    Version: 1.14.0
    Summary: NumPy: array processing for numbers, strings, records, and objects.
    Home-page: http://www.numpy.org
    Author: NumPy Developers
    Author-email: numpy-discussion@python.org
    License: BSD
    Location: /Users/lab/miniconda2/lib/python2.7/site-packages
    Requires:
    Required-by: tensorly, tensorflow, tensorflow-tensorboard, scipy, patsy, pandas, nitime, nipype, mxnet, matplotlib, Keras, h5py
    

    You can see the location field:

    Location: /Users/lab/miniconda2/lib/python2.7/site-packages
    

    This means that to make it run properly, I need to use:

    python2 myscript.py
    

    If you want to use python 3. then use

    pip3 install pydot
    

    and then

    python3 myscript.py