1

In porting my open source project from Python 2.7 to Python 3.4 I need to install the sklearn.cluster package on my computer running Windows 7 Professional (Service Pack 1, 64bit). I did a fresh Miniconda3 installation (64bit) and created a Python 3.4 environment:

conda create -n P34 python=3.4
activate P34

I then installed scikit-learn:

conda install scikit-learn

At this point the environment comprises the following packages:

# packages in environment at C:\Users\rolf\Miniconda3\envs\P34:
#
intel-openmp              2018.0.0             hd92c6cd_8  
mkl                       2017.0.4             h6d528fc_0  
numpy                     1.11.3                   py34_0  
pip                       9.0.1                    py34_1  
python                    3.4.5                         0  
scikit-learn              0.18.1              np111py34_1  
scipy                     0.19.1              np111py34_0  
setuptools                27.2.0                   py34_1  
vc                        10                            0  
vs2010_runtime            10.00.40219.1                 2  
wheel                     0.29.0                   py34_0  

When I now run:

from sklearn.cluster import DBSCAN

I get the following error message:

Traceback (most recent call last):
  File "D:/SW-Development/Python/Test_Programs_Python3/Sklearn/sklearn_cluster.py", line 2, in <module>
    from sklearn.cluster import DBSCAN
  File "C:\Users\rolf\Miniconda3\envs\P34\lib\site-packages\sklearn\__init__.py", line 57, in <module>
    from .base import clone
  File "C:\Users\rolf\Miniconda3\envs\P34\lib\site-packages\sklearn\base.py", line 12, in <module>
    from .utils.fixes import signature
  File "C:\Users\rolf\Miniconda3\envs\P34\lib\site-packages\sklearn\utils\__init__.py", line 11, in <module>
    from .validation import (as_float_array,
  File "C:\Users\rolf\Miniconda3\envs\P34\lib\site-packages\sklearn\utils\validation.py", line 18, in <module>
    from ..utils.fixes import signature
  File "C:\Users\rolf\Miniconda3\envs\P34\lib\site-packages\sklearn\utils\fixes.py", line 291, in <module>
    from scipy.sparse.linalg import lsqr as sparse_lsqr
  File "C:\Users\rolf\Miniconda3\envs\P34\lib\site-packages\scipy\sparse\linalg\__init__.py", line 113, in <module>
    from .isolve import *
  File "C:\Users\rolf\Miniconda3\envs\P34\lib\site-packages\scipy\sparse\linalg\isolve\__init__.py", line 6, in <module>
    from .iterative import *
  File "C:\Users\rolf\Miniconda3\envs\P34\lib\site-packages\scipy\sparse\linalg\isolve\iterative.py", line 7, in <module>
    from . import _iterative
ImportError: DLL load failed: %1 ist keine zulässige Win32-Anwendung.

Process finished with exit code 1

I know that I'm not the first one running into this problem (see, for example, this thread). I tried all the suggestions I found (e.g. use other installers), but nothing worked for me.

Any idea what I can do to get scikit-learn to work on Python 3?

Rolf
  • 11
  • 2
  • I don't think this is a scikit-learn problem but a problem with scipy. The error happens when sklearn tries to do `from scipy.sparse.linalg import lsqr`. – MB-F Dec 12 '17 at 07:51
  • Thank you for this advice. So, conda installs a wrong version of scipy along with scikit-learn? I had tried to make things as easy for conda as possible and, therefore, started with a fresh Miniconda where I immediately installed scikit-learn. – Rolf Dec 12 '17 at 08:36
  • I don't really know what the issue is. Normally libraries should match, and it looks like this is the case here. You can of course try to reinstall numpy and scipy. However, I strongly suspect something else is going wrong here. I *think* you get this error message when trying to load a 64 bit DLL from a 32 bit application. Try to find out which particular DLL file is being loaded. (I once have seen a system where scipy was loading the wrong version of a DLL because MATLAB came first in the search path; maybe something similar is going on here...) – MB-F Dec 12 '17 at 08:41
  • Meanwhile I followed the solution proposed in [link](https://stackoverflow.com/questions/46631108/error-importing-sklearn?rq=1). I uninstalled numpy, scipy and scikit-learn, and installed the packages from Christoph Gohlke's website using pip. So far it seems to work. I had hesitated to mix the use of conda and pip, but there seems to be no way around this. – Rolf Dec 12 '17 at 08:45

0 Answers0