Search code examples
pythonscikit-learnpipanacondascikit-image

import skimage not a Valid Win32 application python3


I'm trying to run this file which requires skimage. So, I installed scikit-image using pip install scikit-image. But when I run the file, I get this error:

Traceback (most recent call last):
  File "D:/Studies/07) IISC/Academics/1st Sem/E9 241 - Digital Image Processing/Assignments/FinalProject/Codes/tensorlayer/tensorlayer/examples/pretrained_cnn/tutorial_vgg19.py", line 18, in <module>
    import skimage
  File "D:\Workspaces\Anaconda\envs\dip_project\lib\site-packages\skimage\__init__.py", line 167, in <module>
    from .util.dtype import (img_as_float32,
  File "D:\Workspaces\Anaconda\envs\dip_project\lib\site-packages\skimage\util\__init__.py", line 12, in <module>
    from ._montage import montage, montage2d
  File "D:\Workspaces\Anaconda\envs\dip_project\lib\site-packages\skimage\util\_montage.py", line 2, in <module>
    from .. import exposure
  File "D:\Workspaces\Anaconda\envs\dip_project\lib\site-packages\skimage\exposure\__init__.py", line 1, in <module>
    from .exposure import histogram, equalize_hist, \
  File "D:\Workspaces\Anaconda\envs\dip_project\lib\site-packages\skimage\exposure\exposure.py", line 4, in <module>
    from ..color import rgb2gray
  File "D:\Workspaces\Anaconda\envs\dip_project\lib\site-packages\skimage\color\__init__.py", line 1, in <module>
    from .colorconv import (convert_colorspace,
  File "D:\Workspaces\Anaconda\envs\dip_project\lib\site-packages\skimage\color\colorconv.py", line 369, in <module>
    rgb_from_xyz = linalg.inv(xyz_from_rgb)
  File "D:\Workspaces\Anaconda\envs\dip_project\lib\site-packages\scipy\linalg\basic.py", line 946, in inv
    a1 = _asarray_validated(a, check_finite=check_finite)
  File "D:\Workspaces\Anaconda\envs\dip_project\lib\site-packages\scipy\_lib\_util.py", line 228, in _asarray_validated
    import scipy.sparse
  File "D:\Workspaces\Anaconda\envs\dip_project\lib\site-packages\scipy\sparse\__init__.py", line 229, in <module>
    from .csr import *
  File "D:\Workspaces\Anaconda\envs\dip_project\lib\site-packages\scipy\sparse\csr.py", line 15, in <module>
    from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
ImportError: DLL load failed: %1 is not a valid Win32 application.

I searched on google as well as on StackOverflow. Many answers suggested to download and install 64-bit version of scikit-image. I tried that, with no luck. This answer suggested to install 64-bit version of Pillow. I tried that, with no luck.

I'm using python 3.7 on a 64-bit windows 8.1. I'm using python inside a virtual env created by Anaconda3.
So, I even tried conda install scikit-image. This upgraded my numpy and a whole lot of others, but didn't solve the issue. Instead, after doing this step, i wasn't even able to import numpy, cv2 and others. conda remove scikit-image got me back to previous state. I have even tried creating a whole new conda environment, but same issue.

I'm completely stuck here with no idea about how to proceed. Please help!!!


Solution

  • Using Python 3.6 resolved this error, I have no idea how or why! I followed the below steps and is working fine

    conda create -n test01 python=3.6
    conda install scikit-image
    

    Another thing which I'm not sure matters or not is that I was launching spyder from anaconda prompt. But it turned out spyder was not installed in the env 'test01'. So, when I opened Anaconda Navigator, there was an option to install spyder. I installed spyder again and opened spyder there and it worked.