Python Forum
Cannot run scikit-image in Python 3.6
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot run scikit-image in Python 3.6
#1
I am trying to run a small piece of code in Python 3.6 from scikit-image. I've loaded scikit-image and the pieces seem to be there. Here is the code:

import numpy as np
from skimage import data
coins = data.coins()
histo = np.histogram(coins, bins=np.arange(0, 256))
Here is the error:

Error:
runfile('C:/Users/franc/Anaconda3/Lib/site-packages/numpy/core/coin_histogram.py', wdir='C:/Users/franc/Anaconda3/Lib/site-packages/numpy/core') Traceback (most recent call last): File "<ipython-input-25-e62c5588c948>", line 1, in <module> runfile('C:/Users/franc/Anaconda3/Lib/site-packages/numpy/core/coin_histogram.py', wdir='C:/Users/franc/Anaconda3/Lib/site-packages/numpy/core') File "C:\Users\franc\Anaconda3_new\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile execfile(filename, namespace) File "C:\Users\franc\Anaconda3_new\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace) File "C:/Users/franc/Anaconda3/Lib/site-packages/numpy/core/coin_histogram.py", line 4, in <module> from skimage import data File "C:\Users\franc\Anaconda3_new\lib\site-packages\skimage\data\__init__.py", line 16, in <module> from ..io import imread, use_plugin File "C:\Users\franc\Anaconda3_new\lib\site-packages\skimage\io\__init__.py", line 7, in <module> from .manage_plugins import * File "C:\Users\franc\Anaconda3_new\lib\site-packages\skimage\io\manage_plugins.py", line 28, in <module> from .collection import imread_collection_wrapper File "C:\Users\franc\Anaconda3_new\lib\site-packages\skimage\io\collection.py", line 12, in <module> from PIL import Image File "C:\Users\franc\Anaconda3_new\lib\site-packages\PIL\Image.py", line 56, in <module> from . import _imaging as core ImportError: DLL load failed: The specified module could not be found.
No matter what I run from scikit-image I get a similar error.

I am able to run scikit-learn, tensorflow, pretty much everything but cannot run scikit-image.

Tearing my hair out.
Reply
#2
In same error message it jumps franc/Anaconda3/ Doh franc\Anaconda3_new
Reply
#3
Yes good observation. But I discovered I could run other more complex code. I believe the problem lies in other pieces of code that it calls, particularly
from . import _imaging as core
I don't think that the jumping from Anaconda3 to Anaconda3_new makes a difference. For example I can run
import numpy as np
import matplotlib.pyplot as plt

from skimage import measure


# Construct some test data
x, y = np.ogrid[-np.pi:np.pi:100j, -np.pi:np.pi:100j]
r = np.sin(np.exp((np.sin(x)**3 + np.cos(y)**2)))

# Find contours at a constant value of 0.8
contours = measure.find_contours(r, 0.8)

# Display the image and plot all contours found
fig, ax = plt.subplots()
ax.imshow(r, interpolation='nearest', cmap=plt.cm.gray)

for n, contour in enumerate(contours):
    ax.plot(contour[:, 1], contour[:, 0], linewidth=2)

ax.axis('image')
ax.set_xticks([])
ax.set_yticks([])
plt.show()
with no problem. Thank youi
Reply
#4
You should only have one Anaconda instantiation.
If it work in some scenarios dos not mean that it work in all(should not jump at all).
It easy to create isolated virtual environment,so no need for two main installation.
Example:
# Make enviroment
G:\Anaconda3\Scripts
λ conda create -n sci_env scikit-image numpy    

# Activate
G:\Anaconda3\Scripts
λ activate sci_env

(sci_env) G:\Anaconda3\Scripts
λ which python
/g/Anaconda3/envs/sci_env/python

# Run your first code added print(histo)
(sci_env) G:\Anaconda3\envs\sci_env
λ python sci_test.py
Output:
(array([ 0, 1, 2, 7, 10, 7, 10, 27, 16, 14, 17, ....................................... 247, 248, 249, 250, 251, 252, 253, 254, 255]))
So working and totally isolated from main version.
You can look at my tutorial about Anaconda
Reply
#5
Yes I agree it would be cleaner to have one Anaconda instantiation. However here is an example where only one Anaconda instantiation is invoked and the same errors occur
Error:
runfile('C:/Users/franc/Anaconda3_new/Lib/site-packages/PIL/hough_transform.py', wdir='C:/Users/franc/Anaconda3_new/Lib/site-packages/PIL') Traceback (most recent call last): File "<ipython-input-61-268539df075b>", line 1, in <module> runfile('C:/Users/franc/Anaconda3_new/Lib/site-packages/PIL/hough_transform.py', wdir='C:/Users/franc/Anaconda3_new/Lib/site-packages/PIL') File "C:\Users\franc\Anaconda3_new\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile execfile(filename, namespace) File "C:\Users\franc\Anaconda3_new\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace) File "C:/Users/franc/Anaconda3_new/Lib/site-packages/PIL/hough_transform.py", line 6, in <module> from skimage import data File "C:\Users\franc\Anaconda3_new\lib\site-packages\skimage\data\__init__.py", line 16, in <module> from ..io import imread, use_plugin File "C:\Users\franc\Anaconda3_new\lib\site-packages\skimage\io\__init__.py", line 7, in <module> from .manage_plugins import * File "C:\Users\franc\Anaconda3_new\lib\site-packages\skimage\io\manage_plugins.py", line 28, in <module> from .collection import imread_collection_wrapper File "C:\Users\franc\Anaconda3_new\lib\site-packages\skimage\io\collection.py", line 12, in <module> from PIL import Image File "C:\Users\franc\Anaconda3_new\lib\site-packages\PIL\Image.py", line 56, in <module> from . import _imaging as core ImportError: DLL load failed: The specified module could not be found.
I believe it is in the module

from . import _imaging as core 
Reply
#6
Try update pillow.
conda update pillow
Error is reported here
See that downgrade work for some.
conda uninstall pillow
conda install pillow=4.0.0
The problem should be fixed in Python 3.6.1 -->
Reply
#7
try conda install -c conda-forge pillow=4.3.0
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  scikit-tensor package Lamine 1 2,575 Feb-27-2022, 01:16 PM
Last Post: jefsummers
  SciKit vs Dynamo vs Grasshopper/Dodo for A.I. Planner Project Julian 1 2,886 Jun-10-2019, 02:41 AM
Last Post: Larz60+
  Possible Scikit-Learn Import Issue? BlackHeart 2 7,165 Oct-26-2017, 04:07 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020