4
votes

I'm not sure what's going on here. I installed Python with Anaconda, there are no previous versions of Python installed. Everything works fine with Spyder, Jupyter Notebooks, or within Anaconda prompt itself. When I try to run numpy or pandas in cmd, I get an error. When I run them in Anaconda prompt, no issue.

Here's how it looks in Anaconda prompt

How it looks in CMD

Looks like both prompts are pointing to the exact same installation of Python. I've even ran python.exe from the Anaconda install folder and get the same error.

My Environment Variable path points to C:\Anaconda , where the python.exe is found. Any ideas as to what's going on?

Edit: I noticed I import numpy on the conda screenshot and I'm trying to import numpy on the cmd screenshot. Importing either pandas or numpy on conda loads it successfully.

Edit 2: Opening python.exe within the Anaconda folder gives the same output. Can't import numpy/pandas. Opening Anaconda Navigator -> base (root) -> Open with Python successfully imports numpy/pandas. How can the python.exe within Anaconda not detect libraries installed by Anaconda... yet running Python within Anaconda Navigator works?

Edit 3: SOLVED Ended up uninstalling and reinstalling both Pandas and Numpy through Anaconda prompt. Really odd but now both packages work regardless if I use Conda prompt or cmd.

1
Please don't post code/terminal output in images. See here for why: meta.stackoverflow.com/a/285557/2449192 - darthbith
Why do you want to run Python from the normal command prompt if it works from the Anaconda prompt? - darthbith
I was using pycharm and my code wouldn't run in there despite setting the interpreter to the Anaconda. After investigating a bit I realized the problem occurred in normal cmd as well. Figured if I can get it working there, it will also work in Pycharm. - Tappy

1 Answers

3
votes

Try upgrading the pip first and then try to uninstall if they are already present in the below order.

pip uninstall pandas
pip uninstall numpy
pip install pandas
pip install numpy