如何修复“在Windows上的'Ipython'和'Jupyter Notebook'中导入熊猫失败”

时间:2019-08-31 10:14:21

标签: python pandas jupyter

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

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

    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笔记本中导入熊猫时收到错误消息:

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

-
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

我尝试卸载并重新安装熊猫,但是没有运气

2 个答案:

答案 0 :(得分:1)

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

!pip install pandas

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

您很可能已将熊猫安装到其他虚拟环境中。

答案 1 :(得分:0)

如果您尝试使用其他解释器来运行代码(例如Visual Studio Code)或从终端运行,有时解释器的模块目录可能与使用pip的模块安装目录不同。