ImportError: No module named 'sklearn.__check_build._check_build' - scikit-learn

ModuleNotFoundError Traceback (most recent call last)
~\AppData\Roaming\Python\Python36\site-packages\sklearn\__check_build\__init__.py in <module>()
43 try:
---> 44 from ._check_build import check_build # noqa
45 except ImportError as e:
ModuleNotFoundError: No module named
'sklearn.__check_build._check_build'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-1-f14d678f34eb> in <module>()
1 from keras.models import Sequential
2 from keras.layers import Dense, Dropout
----> 3 from sklearn.model_selection import train_test_split
4 import numpy
5 import pandas as pd
~\AppData\Roaming\Python\Python36\site-packages\sklearn\__init__.py in <module>()
61 # process, as it may not be compiled yet
62 else:
---> 63 from . import __check_build
64 from .base import clone
65 from .utils._show_versions import show_versions
~\AppData\Roaming\Python\Python36\site-packages\sklearn\__check_build\__init__.py in <module>()
44 from ._check_build import check_build # noqa
45 except ImportError as e:
---> 46 raise_build_error(e)
~\AppData\Roaming\Python\Python36\site-packages\sklearn\__check_build\__init__.py in raise_build_error(e)
39 to build the package before using it: run `python setup.py install` or
40 `make` in the source directory.
---> 41 %s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
42
43 try:
ImportError: No module named 'sklearn.__check_build._check_build'
Contents of C:\Users\owaisaaa\AppData\Roaming\Python\Python36\site-packages\sklearn\__check_build:
setup.py _check_build.cp36-win32.pyd__init__.py
__pycache__
It seems that scikit-learn has not been built correctly.
If you have installed scikit-learn from source, please do not forget
to build the package before using it: run python setup.py install or
make in the source directory.
If you have used an installer, please check that it is suited for your
Python version, your operating system and your platform.
I recently used the pycharm on the same machine and downloaded the packages in it. From that moment onward I am getting the above mentioned error in my jupyter notebook.

Try installing scipy and restarting python shell

Upgrading scikit-learn worked for me:
$ pip install --upgrade scikit-learn

Related

while attempting to import module of sklearn in Jupiter notebook as well as in PYCHARM, i continuously get following error

i have installed scikit-learn using pip command, however while trying to import module of sklearn in Jupiter notebook as well as in PYCHARM, i continuously get following error. I am working in python3.9. I am new to the interface, so it is requested to suggest solution for this issue.
ImportError Traceback (most recent call last)
in
----> 1 import sklearn.linear_model as lm
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sklearn/init.py in
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
83 from .utils._show_versions import show_versions
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sklearn/__check_build/init.py in
44 from ._check_build import check_build # noqa
45 except ImportError as e:
---> 46 raise_build_error(e)
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sklearn/__check_build/init.py in raise_build_error(e)
29 else:
30 dir_content.append(filename + '\n')
---> 31 raise ImportError("""%s
32 ___________________________________________________________________________
33 Contents of %s:
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sklearn/__check_build/_check_build.cpython-39-darwin.so, 2): Symbol not found: ____chkstk_darwin
Referenced from: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sklearn/__check_build/../.dylibs/libomp.dylib
Expected in: /usr/lib/libSystem.B.dylib
in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sklearn/__check_build/../.dylibs/libomp.dylib
Contents of /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/sklearn/__check_build:
init.py pycache _check_build.cpython-39-darwin.so
setup.py
It seems that scikit-learn has not been built correctly.
If you have installed scikit-learn from source, please do not forget
to build the package before using it: run python setup.py install or
make in the source directory.
If you have used an installer, please check that it is suited for your
Python version, your operating system and your platform
thanks
As you can see in this bug report, the new sklearn version 0.24 crashes on MacOS<10.15 systems.
Until this bug is fixed, the developers suggest installing the previous version using pip install -U scikit-learn==0.23.

Is there a way to import train_test_ spit in sklearn?

I am getting this error after I run my test. This is beyond frusterating.
ImportError Traceback (most recent call last)
<ipython-input-3-3cd21e54f349> in <module>()
81 from tensorflow.keras.models import Sequential
82 from sklearn import preprocessing
---> 83 from sklearn.feature_selection import train_test_split
84
85
ImportError: cannot import name 'train_test_split'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
It looks like you did not use pip to install sklearn. In the terminal you should run:
pip install scikit-learn
and make sure it runs without errors.

got "No module named 'tensorflow.python.platform' " when try to import TensorFlow 2.0

I installed the latest anaconda navigator 1.9.7 (windows 10), and created a new env (python 3.7)in the anaconda navigator interface, then installed jupyter notebook and tensorflow 2.0 package in it.
when I tried to import tensorflow as follow
import tensorflow as tf
I got this error
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-64156d691fe5> in <module>
----> 1 import tensorflow as tf
~\AppData\Roaming\Python\Python37\site-packages\tensorflow\__init__.py in <module>
26
27 # pylint: disable=g-bad-import-order
---> 28 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
29 from tensorflow.python.tools import module_util as _module_util
30
~\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\__init__.py in <module>
47 import numpy as np
48
---> 49 from tensorflow.python import pywrap_tensorflow
50
51 # Protocol buffers
~\AppData\Roaming\Python\Python37\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
23 import traceback
24
---> 25 from tensorflow.python.platform import self_check
26
27
ModuleNotFoundError: No module named 'tensorflow.python.platform'
i tried use
pip uninstall tensorflow
pip install tensorflow
and
redid it inside that directory
nothing worked so far.
any suggestion?
If you clone from git ,you can
just change the folder from the one where you run the configure/bazel and then try python import tensorflow as tf

How to fix 'cannot initialize type TensorProto DataType' error while importing torch?

I installed pytorch using pip3 command for my windows pc without GPU support.
But when I tried to import torch it is giving an error.
At first, there was a different error saying numpy version not matching and I updated the numpy to the latest version.
import torch
RuntimeError Traceback (most recent call last)
<ipython-input-10-c031d3dd82fc> in <module>()
----> 1 import torch
C:\Users\iamuraptha\Anaconda3\lib\site-packages\torch\__init__.py in <module>()
82 pass
83
---> 84 from torch._C import *
85
86 __all__ += [name for name in dir(_C)
RuntimeError: generic_type: cannot initialize type "TensorProtoDataType": an object with that name is already defined
I reinstalled anaconda and then created a virtual environment for pytorch.Now everything works fine
If you are running this in colab, remember to restart your runtime after installing your modules with pip.

Using pytables with python3 fails

importing pytables (3.1.1) in python 3.4.1 fails for me, complaining about a failed cPickle import
i try to use potables (3.1.1) with python (3.4.1)
In [1]: import tables
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-389ecae14f10> in <module>()
----> 1 import tables
/work/projects/vEnv/lib/python3.4/site-packages/tables/__init__.py in <module>()
80
81 # Necessary imports to get versions stored on the cython extension
---> 82 from tables.utilsextension import (
83 get_pytables_version, get_hdf5_version, blosc_compressor_list,
84 blosc_compcode_to_compname_ as blosc_compcode_to_compname,
/work/projects/vEnv/lib/python3.4/site-packages/tables/utilsextension.pyx in init tables.utilsextension (tables/utilsextension.c:15600)()
/work/projects/vEnv/lib/python3.4/site-packages/tables/description.py in <module>()
22 import numpy
23
---> 24 from tables import atom
25 from tables.path import check_name_validity
26
/work/projects/vEnv/lib/python3.4/site-packages/tables/atom.py in <module>()
18 import sys
19 import inspect
---> 20 import cPickle
21
22 import numpy
As i understand cPickle is only used instead of pickle in python2.
As of PyTable 3.x it should work fine with python3.x. How can there be a cPickle import than?
What do i have to do to use pytables with python3?
The error was produced most likely due to a problem with my vEnv. Uninstalling the package and reinstalling it fix the problem.
See github issue

Resources