1

While trying to import sklearn, i come across the following error message : AttributeError: module 'numpy' has no attribute '__config__'

I did install and updated both numpy and sklearn with conda but still get the same error. Any ideas?

import sklearn

Get error message:

Traceback (most recent call last):

  File "<ipython-input-35-b7c74cbf5af0>", line 1, in <module>
    import sklearn

  File "C:\Users\sound\Documents\Conda\lib\site-packages\sklearn\__init__.py", line 82, in <module>
    from .base import clone

  File "C:\Users\sound\Documents\Conda\lib\site-packages\sklearn\base.py", line 20, in <module>
    from .utils import _IS_32BIT

  File "C:\Users\sound\Documents\Conda\lib\site-packages\sklearn\utils\__init__.py", line 20, in <module>
    from scipy.sparse import issparse

  File "C:\Users\sound\Documents\Conda\lib\site-packages\scipy\sparse\__init__.py", line 229, in <module>
    from .base import *

  File "C:\Users\sound\Documents\Conda\lib\site-packages\scipy\sparse\base.py", line 7, in <module>
    from scipy._lib._numpy_compat import broadcast_to

  File "C:\Users\sound\Documents\Conda\lib\site-packages\scipy\_lib\_numpy_compat.py", line 16, in <module>
    _assert_warns = np.testing.assert_warns

  File "C:\Users\sound\Documents\Conda\lib\site-packages\numpy\__init__.py", line 213, in __getattr__
    import numpy.testing as testing

  File "C:\Users\sound\Documents\Conda\lib\site-packages\numpy\testing\__init__.py", line 12, in <module>
    from ._private.utils import *

  File "C:\Users\sound\Documents\Conda\lib\site-packages\numpy\testing\_private\utils.py", line 57, in <module>
    HAS_LAPACK64 = hasattr(numpy.__config__, 'lapack_ilp64_opt_info')

  File "C:\Users\sound\Documents\Conda\lib\site-packages\numpy\__init__.py", line 220, in __getattr__
    "{!r}".format(__name__, attr))

AttributeError: module 'numpy' has no attribute '__config__'
---
4
  • What's your numpy version? Commented Mar 24, 2020 at 13:12
  • Hi.numpy version : 1.18.1 Commented Mar 24, 2020 at 13:49
  • Uninstall sklearn, uninstall numpy, install numpy, install sklearn. It should work. Commented Mar 24, 2020 at 14:38
  • I did that already and it does not help, could it be that it has to do with the numpy version? Commented Mar 24, 2020 at 16:22

2 Answers 2

2

I had the exact same problem using the binary numpy 1.18.1 package from piwheels on my RasperryPi 4. Do you also happen to try to use this on a Raspberry Pi?

If yes, then:

It works after uninstalling numpy and then retrieving numpy 1.18.1 from pypi instead of from piwheels (had to compile from source though - it takes roughly 15 minutes).

There seems to be something wrong with the piwheels package - I don't know what it is.

The following two commands should solve your problem:

pip3 uninstall numpy
pip3 install numpy==1.18.1 --no-binary :all:

The first command uninstalls your numpy package. The second one retrieves numpy version 1.18.1 where the switch --no-binary :all: tells pip to not get any binary packages, i.e. from piwheels, but instead compile from source.

Sign up to request clarification or add additional context in comments.

Comments

0

The error may occur if the installation is incomplete while you are installing numpy. That means your numpy was installed with abnormal conditions. For example, you need to type --user to install it, but you didn't. The solution is to erase numpy and reinstall it normally. Note that if you're using the previously installed numpy somewhere on your computer, it won't erase clearly. Try turning off all the programs, leaving only cmd on, erasing numpy and reinstalling. If it doesn't work, you're installing the numpy wrong again. Use --user to install or check other parts.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.