Search code examples
pythontqdm

Error when importing the tqdm module in Python


I have a script that imports the Python tqdm module.

I can import the tqdm module from a Jupyter notebook, for instance, but not when running the script from the command line.

When running the script from the command line, I see the following error message:

File "RetreiveData.py", line 19, in <module> from tqdm import tqdm
    ImportError: No module named tqdm

My script is called from a command line as follows:

python RetrieveData.py <arg1> <arg2>

My environment variables are:

PATH:

C:\Users<joesmith\AppData\Local\Continuum\Anaconda2;C:\Users\joesmith\AppData\Local\Continuum\Anaconda2\Scripts;C:\Users\joesmith\AppData\Local\Continuum\Anaconda2\Library\bin; C:\Company\Libs\python-2.7\Windows_x86

PYTHON PATH:

C:\Users\joesmith\AppData\Local\Continuum\Anaconda2;C:\Users\joesmith\AppData\Local\Continuum\Anaconda2\Scripts;C:\Users\joesmith\AppData\Local\Continuum\Anaconda2\Library\bin; C:\Company\Libs\python-2.7\Windows_x86

Does anyone see why this error is occurring?

Thanks!


Solution

  • In Anaconda this worked for me:

    sudo <anaconda path>/bin/python3.6 -m pip install tqdm 
    

    (after your working env is activated)

    On my linux machine I substituted <anaconda path> with:

    anaconda3
    

    In your machine try with Anaconda2 once inside your working env for your machine like so:

    sudo Anaconda2/Library/bin/python-2.7 -m pip install tqdm
    

    Make sure you have pip installed.