即使安装了熊猫也无法正常工作

时间:2020-05-16 00:49:24

标签: python pandas anaconda

我已经使用Anaconda库安装了python和pandas,但是当我尝试在Jupyter Notebook或Python Idle中导入熊猫时,它不起作用。当我在终端中运行shell时,它确实起作用。

我正在使用macOS Mojave和Python版本3.7.6。

在终端上,它说我已经安装了熊猫,如下图所示。

enter image description here

但是,尝试将其导入Python空闲状态时,出现错误消息“ ModuleNotFoundError:没有名为'pandas'的模块”。

enter image description here

我想我知道问题出在哪里,但我不知道如何解决或解决它。我在2年前安装了Anaconda,并使用了它,但是在完成它的使用以在计算机中腾出空间后将其删除,现在我重新安装了它。因此,我认为Idle和Jupyter Notebook使用的Python版本与Anaconda软件包中使用的版本不同。我可能完全错了。

谢谢您的帮助!

3 个答案:

答案 0 :(得分:1)

如果要使用Anaconda,只需执行以下操作:

conda install pandas

混合conda和pip可能会导致问题。

希望对您有所帮助。请告诉我是否可以解决您的问题。

答案 1 :(得分:1)

您可能没有在运行Jupyter内核的环境中安装熊猫。

您可以通过运行$("<div>— hold to read</div>").appendTo('div.image:not(:has( a[title="divider-picture"]))');直接从Jupyter笔记本电脑安装它。它将安装在内核启动的环境中。

通常,从jupyter notebook运行<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="image"> <a itemprop="image" title="main-picture" data-rel="prettyPhoto[single_pretty_photo]" href="#"> <img itemprop="image" src="#" alt="main"> </a> <div class="img__label_layer">— hold to read</div> <span class="holdtoview"><div class="actionin">TEXT</div></span> </div> <div class="image"> <a itemprop="image" title="divider-picture" data-rel="prettyPhoto[single_pretty_photo]" href="#"> <img itemprop="image" src="#" alt="div8"> </a> <div class="img__label_layer">— hold to read</div> <span class="holdtoview"> <div class="actionin">TEXT</div> </span> </div>应该会向您显示所有已安装的库。如果您在运行!pip install pandas之后没有大熊猫,那么您的环境路径就会被破坏。

在这种情况下,建议您安装anaconda和jupyter,然后重新开始。

如果您想进一步了解内核以及软件包如何在其中工作,https://biasandvariance.com/importing-packages-in-jupyter-notebook/可能会有所帮助。

答案 2 :(得分:0)

您可以尝试更新熊猫吗?

pip install --upgrade pandas