使用 anaconda 的 jupyter notebook 安装 pandas 时出错

Posted

技术标签:

【中文标题】使用 anaconda 的 jupyter notebook 安装 pandas 时出错【英文标题】:Error while installing pandas using anaconda's jupyter notebook 【发布时间】:2020-10-02 01:36:40 【问题描述】:

我使用 anaconda 提示符安装了 pandas。 使用以下命令:-

pip install pandas

并得到以下消息:-

Requirement already satisfied: pandas in c:\users\maini_\anaconda3\lib\site-packages (1.0.3)
Requirement already satisfied: numpy>=1.13.3 in c:\users\maini_\anaconda3\lib\site-packages (from pandas) (1.18.1)
Requirement already satisfied: pytz>=2017.2 in c:\users\maini_\anaconda3\lib\site-packages (from pandas) (2020.1)
Requirement already satisfied: python-dateutil>=2.6.1 in c:\users\maini_\anaconda3\lib\site-packages (from pandas) (2.8.1)
Requirement already satisfied: six>=1.5 in c:\users\maini_\anaconda3\lib\site-packages (from python-dateutil>=2.6.1->pandas) (1.15.0)

但是当我使用以下命令将其导入 Jupiter 笔记本时:-

import pandas as pd

我收到以下错误:-

 ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    <ipython-input-3-7dd3504c366f> in <module>
    ----> 1 import pandas as pd

    ~\anaconda3\lib\site-packages\pandas\__init__.py in <module>
         30 
         31 try:
    ---> 32     from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
         33 except ImportError as e:  # pragma: no cover
         34     # hack but overkill to use re

    ~\anaconda3\lib\site-packages\pandas\_libs\__init__.py in <module>
          1 # flake8: noqa
          2 
    ----> 3 from .tslibs import (
          4     NaT,
          5     NaTType,

    ~\anaconda3\lib\site-packages\pandas\_libs\tslibs\__init__.py in <module>
          1 # flake8: noqa
          2 
    ----> 3 from .conversion import localize_pydatetime, normalize_date
          4 from .nattype import NaT, NaTType, iNaT, is_null_datetimelike
          5 from .np_datetime import OutOfBoundsDatetime

    pandas\_libs\tslibs\conversion.pyx in init pandas._libs.tslibs.conversion()

    AttributeError: type object 'pandas._libs.tslibs.conversion._TSObject' has no attribute '__reduce_cython__'

我也试过这个命令

python -m pip install pandas

并收到以下消息

Requirement already satisfied: pandas in c:\users\maini_\anaconda3\lib\site-packages (1.0.3)
Requirement already satisfied: numpy>=1.13.3 in c:\users\maini_\anaconda3\lib\site-packages (from pandas) (1.18.1)
Requirement already satisfied: python-dateutil>=2.6.1 in c:\users\maini_\anaconda3\lib\site-packages (from pandas) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in c:\users\maini_\anaconda3\lib\site-packages (from pandas) (2020.1)
Requirement already satisfied: six>=1.5 in c:\users\maini_\anaconda3\lib\site-packages (from python-dateutil>=2.6.1->pandas) (1.15.0)

请帮助我。提前谢谢你。

【问题讨论】:

在 Windows 计算机上的 anaconda 环境中安装 pandas 的最简单方法可以说是pip uninstall pandas,然后是conda install pandas。如果你正在使用带有 anaconda 的 notebook,我也可以推荐在 notebook 中使用%conda install &lt;pkg-name&gt; 是的,它奏效了。谢谢!! 【参考方案1】:

由于你使用的是 Anaconda,最好的方法是使用 anaconda 提示符:

conda install pandas

【讨论】:

以上是关于使用 anaconda 的 jupyter notebook 安装 pandas 时出错的主要内容,如果未能解决你的问题,请参考以下文章

anaconda使用jupyter 多个内核共用 添加自动补全插件

anaconda运行jupyter出现application launch errror

anaconda安装和jupyter的使用

Ubuntu anaconda 配置 Jupyter Lab

Anaconda + Jupyter notebook下载使用

Jupyter 使用Anaconda 虚拟环境内核