4

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.

3
  • Please don't post code/terminal output in images. See here for why: meta.stackoverflow.com/a/285557/2449192 Commented Dec 18, 2018 at 20:28
  • 1
    Why do you want to run Python from the normal command prompt if it works from the Anaconda prompt? Commented Dec 18, 2018 at 20:29
  • 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. Commented Dec 18, 2018 at 20:39

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

4 Comments

I ended up doing this minus upgrading pip. Uninstalled/reinstalled pandas and numpy through conda prompt and it works with cmd as well.
@Tappy, so finally it worked right ? Now you will be able to import them as well
Yes, everything works, thank you. I'm still confused how this is possible. I have only one installation of Python (through Anaconda). I have no virtual environments. Conda prompt imported those libraries just fine, cmd prompt failed. Python.exe within Anaconda install folder failed to import those libraries. Python prompt launched from Anaconda Navigator successfully imported those libraries. After reinstalling the packages with pip, I can successfully import the libraries regardless of where I launched Python from. Weird right, what am I not understanding?
I am confused with your base (C:) and (H:) how two different pythons you were trying to access

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.