python - 尝试将 sklearn 数据集导入 Jupyter Notebook 时出现 OSError
问题描述
使用以下代码:
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 进行分析没有任何问题。
我使用的是 Windows,如何正确读取 sklearn Real life 数据集?
解决方案
我现在已经解决了这个问题。我安装了两个版本的 Python,一个在我的 Anaconda 路径中,一个直接下载到我的机器上。机器版本是 32 位,Anaconda 是 64 位,所以我删除了 32 位版本,因为我的电脑是 64 位,而且我使用的是 Anaconda 环境。
推荐阅读
- javascript - 我如何在 Javascript 上显示对象
- python - 如果列表中没有,则显示/隐藏字段
- algorithm - 点交叉路径
- flask - Flask-praetorian,无法将身份验证标头传递给受保护的端点
- node.js - npm: command not found - Gitlab CI 特定的运行器
- c++ - gdb中的list命令没有输出我写的代码
- mongodb - Mongo 是否将日期存储为 UTC?
- eclipse - 如何将日志记录添加到现有的 Eclipse 插件以在 2019-12 年工作?
- arrays - 如何从输入中一次读取多行并将每一行存储在 Python 中的列表中以进行修改?
- java - 将表记录映射到 JPA 实体