Date-A-Scientist - Scikit-Learn Import error

Hello there everyone! I’m getting such a strange error while doing Date-A-Scientist. If I try to import sklearn.linear_model.LinearRegression, I get the error below. It’s my first time working with it sklearn off platform and doing some research, it seems like it’s a file error, I’d just like to check in here if there is some issue on that and maybe start a resourceful thread.

$ C:/Users/Lucas/anaconda3/python.exe "d:/Projetos/Code/Date a Scientist/"
Traceback (most recent call last):
  File "d:/Projetos/Code/Date a Scientist/", line 4, in <module>
    from sklearn.linear_model import LinearRegression
  File "C:\Users\Lucas\anaconda3\lib\site-packages\sklearn\", line 80, in <module>
    from .base import clone
  File "C:\Users\Lucas\anaconda3\lib\site-packages\sklearn\", line 21, in <module>
    from .utils import _IS_32BIT
  File "C:\Users\Lucas\anaconda3\lib\site-packages\sklearn\utils\", line 23, in <module>
    from .class_weight import compute_class_weight, compute_sample_weight
  File "C:\Users\Lucas\anaconda3\lib\site-packages\sklearn\utils\", line 7, in <module>
    from .validation import _deprecate_positional_args
  File "C:\Users\Lucas\anaconda3\lib\site-packages\sklearn\utils\", line 25, in <module>
    from .fixes import _object_dtype_isnan, parse_version
  File "C:\Users\Lucas\anaconda3\lib\site-packages\sklearn\utils\", line 18, in <module>
    import scipy.stats
  File "C:\Users\Lucas\anaconda3\lib\site-packages\scipy\stats\", line 388, in <module>
    from .stats import *
  File "C:\Users\Lucas\anaconda3\lib\site-packages\scipy\stats\", line 180, in <module>
    from . import distributions
  File "C:\Users\Lucas\anaconda3\lib\site-packages\scipy\stats\", line 8, in <module>
    from ._distn_infrastructure import (entropy, rv_discrete, rv_continuous,
  File "C:\Users\Lucas\anaconda3\lib\site-packages\scipy\stats\", line 23, in <module>
    from scipy import optimize
  File "C:\Users\Lucas\anaconda3\lib\site-packages\scipy\optimize\", line 387, in <module>
    from .optimize import *
  File "C:\Users\Lucas\anaconda3\lib\site-packages\scipy\optimize\", line 36, in <module>
    from ._numdiff import approx_derivative
  File "C:\Users\Lucas\anaconda3\lib\site-packages\scipy\optimize\", line 6, in <module>
    from scipy.sparse.linalg import LinearOperator
  File "C:\Users\Lucas\anaconda3\lib\site-packages\scipy\sparse\linalg\", line 114, in <module>
    from .eigen import *
  File "C:\Users\Lucas\anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\", line 9, in <module>
    from .arpack import *
  File "C:\Users\Lucas\anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\", line 20, in <module>
    from .arpack import *
  File "C:\Users\Lucas\anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\", line 43, in <module>
    from . import _arpack
ImportError: DLL load failed while importing _arpack:

I found this which might be helpful(?). You might have to uninstall conda versions and install pip versions of scipy.

Or, this from StackOverflow:

1 Like

Hey Lisa!!

Thank you very much!
I tried uninstalling and installing through pip before, but I actually had to conda uninstall scikit-learn, numpy and scipy. So my recommended commands would be.

conda uninstall scikit-learn numpy scipy
conda remove --force scikit-learn numpy scipy
pip uninstall scikit-learn numpy scipy
pip install -U scikit-learn numpy scipy --user

If it’s somehow unnecessary or dangerous, I’ll edit out!

1 Like

You’re welcome.

Wait, so uninstalling conda versions and installing pip versions doesn’t work?
Did you update pip?

I’m not very familiar with that error though… :thinking:

it did! it did. I just tried getting rid of every version possible of each module in my pc then reinstalled everything.

1 Like

Excellent! :partying_face:
I had forgotten to ask if you had a Mac or PC.

I don’t know if this was the explicit reason but try and avoid mixing packages installed with conda and with pip where possible. If you’re using conda for obtaining packages and environment management then get your packages from conda wherever possible and install any additions through pip last and only if you have to (i.e. there’s no build from conda).

A little info on mixing the two here-


HA! I forgot to mention that too. Good thinkin’!

This is actually great info! Should be lying somewhere around here!
Which one do you prefer? Which one is a more permanent solution as in installing a package once and not having to do anything about it again?

It’s worth noting that there’s no direct equivalence between *conda and pip as they do vastly different things (there’s numerous online discussions about this if you wanted to look into it). See this recent post by @el_cocodrilo for a little more information: Setting Up Conda in Git Bash and have a read of the page on conda myths linked within this post under ‘What is Conda…’ .

Personally I’d boil it down to this; if conda covers all your requirements, then you may as well use it (unless you really disliked it). It performs many different tasks that would require otherwise require several pieces of software to do the same thing. If you have the time it’s worth trying your hand with the alternative to see what the benefits and drawbacks are but there’s plenty of online discussion about the same if you wanted to look into it. Might save you some time to see what other more experienced folk think.