问题描述
我不确定这是怎么回事.我在Anaconda上安装了Python,没有安装以前的Python版本. Spyder,Jupyter Notebooks或Anaconda提示自身都可以正常工作.当我尝试在cmd中运行numpy或pandas时,出现错误.当我在Anaconda提示符下运行它们时,没问题.
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.
看起来像两个提示都指向完全相同的Python安装.我什至从Anaconda安装文件夹中运行了python.exe,并得到了相同的错误.
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.
我的环境变量路径指向C:\ Anaconda,在其中找到python.exe.有什么想法吗?
My Environment Variable path points to C:\Anaconda , where the python.exe is found. Any ideas as to what's going on?
编辑:我注意到我在conda屏幕截图上导入了numpy,并且试图在cmd屏幕截图上导入numpy.在conda上导入pandas或numpy会成功加载它.
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.
在Anaconda文件夹中打开python.exe会得到相同的输出.无法导入numpy/pandas.打开Anaconda Navigator->基本(根)->使用Python打开成功导入numpy/pandas. Anaconda中的python.exe如何无法检测到Anaconda安装的库...却在Anaconda Navigator中运行Python呢?
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?
已解决.最终通过Anaconda提示符卸载并重新安装了Pandas和Numpy.真的很奇怪,但是无论我使用Conda提示符还是cmd,这两个软件包都可以工作.
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.
推荐答案
首先尝试升级点,然后尝试卸载(如果它们已按以下顺序存在).
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
这篇关于Anaconda Prompt找到库,cmd-> Python没有. Python仅与Anaconda软件包一起安装,仅此而已的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!