I have a python script which is running successfully when i run it from spyder. But the same script gives "ImportError: No module named pandas" when run from windows command prompt.
2 Answers
This Q&A mentioned similar problem https://stackoverflow.com/a/10741803/5088142
Can you please check which folders are mentioned in Spyder Tools/PYTHONPATH manager?
Also you can execute the following two lines in Spyder, and identify the location of pandas library:
import pandas
print pandas.__file__
The output should be the path to pandas module Please add this path to Windows path (reference https://docs.python.org/2/using/windows.html)
Python:
import sys
sys.path.append('_location_of_python_lib_')
Windows CMD:
set PYTHONPATH=%PYTHONPATH%;C:\_location_of_python_lib_
Windows:
Simply add this path to your PYTHONPATH environment variable. To do this, go to Control Panel / System / Advanced / Environment variable, and in the "User variables" sections, check if you already have PYTHONPATH. If yes, select it and click "Edit", if not, click "New" to add it. Paths in PYTHONPATH should be separated with ";".
The following link show you how to set environment variable in Windows 7 permanently http://www.nextofwindows.com/how-to-addedit-environment-variables-in-windows-7
7 Comments
You should then install pandas using the windows interpreter.
Open Windows command prompt and type:
pip install pandas
or
easy_install pandas
depending on which package manager you use.