【问题标题】:How to fix "Import Pandas inside 'Ipython' and 'Jupyter Notebook' fails on windows"如何修复“在“Ipython”和“Jupyter Notebook”中导入 Pandas 在 Windows 上失败”
【发布时间】:2019-08-31 10:14:21
【问题描述】:

我的系统上安装了 pandas,但它无法工作并发送错误消息 ModuleNotFoundError:ipython 中没有名为“pandas”的模块。

当我尝试在 ipython 中导入 pandas 时收到错误消息:

    In [1]: import pandas
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-38d4b0363d82> in <module>
----> 1 import pandas

ModuleNotFoundError: No module named 'pandas'

当我尝试在 jupyter notebook 中导入 pandas 时收到错误消息:

--------------------------------------------------------------------------

-
OSError                                   Traceback (most recent call last)
<ipython-input-1-38d4b0363d82> in <module>
----> 1 import pandas

c:\users\user\appdata\local\programs\python\python37-32\lib\site-packages\pandas\__init__.py in <module>
      9 for dependency in hard_dependencies:
     10     try:
---> 11         __import__(dependency)
     12     except ImportError as e:
     13         missing_dependencies.append("{0}: {1}".format(dependency, str(e)))

~\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py in <module>
    138 
    139     # Allow distributors to run custom init code
--> 140     from . import _distributor_init
    141 
    142     from . import core

~\AppData\Roaming\Python\Python37\site-packages\numpy\_distributor_init.py in <module>
     24                 # NOTE: would it change behavior to load ALL
     25                 # DLLs at this path vs. the name restriction?
---> 26                 WinDLL(os.path.abspath(filename))
     27                 DLL_filenames.append(filename)
     28     if len(DLL_filenames) > 1:

c:\users\user\appdata\local\programs\python\python37-32\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    354 
    355         if handle is None:
--> 356             self._handle = _dlopen(self._name, mode)
    357         else:
    358             self._handle = handle

OSError: [WinError 193] %1 is not a valid Win32 application

我已经尝试卸载并重新安装熊猫,但没有成功

【问题讨论】:

  • “我已经尝试卸载并重新安装 pandas 但没有成功”是什么意思。您无法安装或收到已安装的消息?
  • 它说要求已经满足:c:\\users...\lib\site-packages 中的熊猫
  • 大声思考。文件的名称是什么?它有没有机会被命名为“熊猫”?如果是,请更改它。

标签: python pandas jupyter


【解决方案1】:

在您的 iPython Notebook 中,您可以尝试运行以下命令吗?

!pip install pandas

然后重新启动你的 iPython Notebook 内核?

很可能您已将 pandas 安装到不同的虚拟环境中。

【讨论】:

  • 它显示以下输出: 要求已经满足:c:\users\user\appdata\local\programs\python\python37-32\lib\site-packages (0.25.1) 中的 pandas 要求已经满意: pytz>=2017.2 in c:\users\user\appdata\roaming\python\python37\site-packages (from pandas) ....
  • 我建议你卸载你的 python,然后使用 anaconda 发行版重新安装。
【解决方案2】:

您是否尝试过使用不同的解释器来运行代码,例如 Visual Studio Code,或从终端运行,有时解释器可能与使用 pip 安装它们的位置不同的模块目录。

【讨论】:

  • 我使用 anaconda 发行版重新安装了 python。 问题已解决
猜你喜欢
  • 2016-08-28
  • 2016-05-17
  • 1970-01-01
  • 2018-04-23
  • 1970-01-01
  • 2016-12-27
  • 2018-03-29
  • 2023-03-16
  • 2015-10-15
相关资源
最近更新 更多