尝试将 sklearn 数据集导入 Jupyter Notebook 时出现 OSError

OSError when trying to import a sklearn dataset into Jupyter Notebook

使用以下代码:

from sklearn.datasets import fetch_california_housing
housing = fetch_california_housing()
housing

我收到错误:

    OSError                                   Traceback (most recent call last)
<ipython-input-19-b7c74cbf5af0> in <module>
----> 1 import sklearn

~\AppData\Roaming\Python\Python38\site-packages\sklearn\__init__.py in <module>
     78     # later is linked to the OpenMP runtime to make it possible to introspect
     79     # it and importing it first would fail if the OpenMP dll cannot be found.
---> 80     from . import _distributor_init  # noqa: F401
     81     from . import __check_build  # noqa: F401
     82     from .base import clone

~\AppData\Roaming\Python\Python38\site-packages\sklearn\_distributor_init.py in <module>
     20     vcomp140_dll_filename = op.join(libs_path, "vcomp140.dll")
     21     vcruntime140_dll_filename = op.join(libs_path, "vcruntime140.dll")
---> 22     WinDLL(op.abspath(vcomp140_dll_filename))
     23     WinDLL(op.abspath(vcruntime140_dll_filename))

~\Anaconda3\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    371 
    372         if handle is None:
--> 373             self._handle = _dlopen(self._name, mode)
    374         else:
    375             self._handle = handle

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

在我的机器上,我同时安装了 Python 32 位和 64 位,所以我假设问题是我所在的 Jupyter Lab 运行 代码与 运行 的版本不匹配 python 在我的机器上和 sklearn 使用的版本导致问题?

在此之前,我对 sklearn 或使用 Jupyter Notebook 进行分析没有任何问题。

如何在 sklearn Real life dataset 中正确读取,我正在使用 Windows?

我现在已经解决了这个问题。我安装了两个版本的 Python,一个在我的 Anaconda 路径中,一个我直接下载到我的机器上。机器版本是 32 位,Anaconda 64 位,所以我删除了 32 位版本,因为我的电脑是 64 位,而且我使用的是 Anaconda 环境。