3

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
  • Are you using the same interpreter? Commented May 5, 2016 at 12:14
  • I m not sure. How can i check that Commented May 5, 2016 at 12:33

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

7 Comments

I added the path, but now i get a different error : ImportError : C extension : DLL load failed.....If u want to import pandas from source directory, you may need to run python setup.py build_ext....
How did you originally installed pandas? this link stackoverflow.com/q/30945272/5088142 mentioned similar problem in windows " There is a bug in older versions (of conda) where if you had updated pandas WHILE it was being used it didn't update correctly. Try closing all python processes, then conda remove pandas; conda install pandas"
Initially it was installed with Anaconda by default and it is working fine with spyder. Do u still suggest to reinstall pandas ?
Which path did you add?
I have set PYTHONPATH to Appdata\local\Continuum\Anaconda3\lib\site-packages\
|
-3

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.

2 Comments

Can't i somehow use the same libraries that are being used by spyder. spyder is able to find all the packages.
I think he is asking about a problem he encountered while running a python script from command line

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.