Reputation: 1468
I use Python in OSX using Spyder and was recently trying to run a .py file through the command line. Pandas is installed and I've had no problem using it, but when I attempt to run the file or use Python interactively in the terminal, it's unable to find the Pandas module.
No problem with this when I run it in Spyder with the Ipython console:
import pandas as pd
xl = pd.ExcelFile("DDC_Report.xlsx")
However, when I attempt to import pandas in the Unix terminal, I get the following error.
>>> import pandas as pd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pandas
Running script from terminal:
abraham-mathew:~ abraham.mathew$ python Automation_Stacia.py
Traceback (most recent call last):
File "Automation_Stacia.py", line 12, in <module>
import pandas as pd
ImportError: No module named pandas
I'm' running the following:
abraham-mathew:~ abraham.mathew$ python
Python 2.7.8 (v2.7.8:ee879c0ffa11, Jun 29 2014, 21:07:35)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Can anyone help me identify what could be wrong. I'm at a total loss, but have the feeling it may be fairly simple. Thanks!
Upvotes: 0
Views: 545
Reputation: 1675
I haven't worked with Spyder, but this might be a different environment under Spyder or under your normal command line. Try running the following using both methods. Is there a difference in the value of the environment variable PYTHONPATH
?
import os
print os.getenv('PYTHONPATH')
Upvotes: 2