user697911 user697911 - 8 months ago 49
Python Question

python newbie - how to import library

I installed the 'pandas' module and now I need to run it at my command line, but it is not available. How to make it available?

In [1]: import pandas as pd
ImportError Traceback (most recent call last)
<ipython-input-1-af55e7023913> in <module>()
----> 1 import pandas as pd

ImportError: No module named 'pandas'

In [2]:

Answer Source

Your module can't be found in the current directory, in pythons site-packages folder or in any path defined in the $PYTHON_PATH environment variable.

If you installed pandas via pip install pandas and encounter an ImportError, you most likely have a problem due to multiple python distributions installed on your system.

Look carefully at the output of pip install pandas and examine the folders in its output. Find out which executable you are running when calling python via which python and look at the version numbers.

This is a very common problem btw. so prepare for a close of this question.