Home > front end >  OSError when trying to import a sklearn dataset into Jupyter Notebook
OSError when trying to import a sklearn dataset into Jupyter Notebook

Time:11-10

With the code below:

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

I get the error:

    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

On my machine I have both Python 32 and 64 bit installed, so I am assuming the issue is that Jupyter Lab, where I am running the code, is mismatching the version of python on my machine and the version sklearn uses, causing the issue?

I have had no issues with sklearn or using Jupyter Notebook for analysis prior to this.

How do I read in the sklearn Real life dataset with no error, I am using Windows?

CodePudding user response:

I have now solved this. I had two versions of Python installed, one in my Anaconda path and one I downloaded on my machine directly. The machines version was 32 bit, Anaconda 64 bit so I deleted the 32 bit version as my computer is 64 bit, plus I was using the Anaconda environment.

  • Related