Scikit-image: not able to import skimage

Created on 9 Jan 2017  Â·  33Comments  Â·  Source: scikit-image/scikit-image

Description

I'm not able to import skimage in python.

[>> import skimage
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/vrushabh/.local/lib/python2.7/site-packages/skimage/__init__.py", line 156, in <module>
    _raise_build_error(e)
  File "/home/vrushabh/.local/lib/python2.7/site-packages/skimage/__init__.py", line 137, in _raise_build_error
    %s""" % (e, msg))
ImportError: /home/vrushabh/.local/lib/python2.7/site-packages/skimage/_shared/geometry.so: undefined symbol: PyUnicodeUCS4_DecodeUTF8

It seems that scikit-image has not been built correctly.

Your install of scikit-image appears to be broken.
Try re-installing the package following the instructions at:
http://scikit-image.org/docs/stable/install.html 

this is the error

All 33 comments

@vrjgamer how did you install your copy of scikit-image?

using this pip install -U scikit-image

even this:

If your distribution ships an outdated version, you may recompile from source. First install the dependencies:

sudo apt-get install python-matplotlib python-numpy python-pil python-scipy
Get compilers:

sudo apt-get install build-essential cython

@vrjgamer installing with sudo typically copies files to /usr/lib. In your case you have scikit-image installed also(?) into /home/vrushabh/.local/lib. This latter is probably a corrupted installation.
Please, try with /home/vrushabh/.local/lib/python2.7/site-packages/skimage removed.

@vrjgamer any news?

sry for the late reply,
i reinstalled ubuntu and it worked i think it was problem with my system
sry and thank you for ur time.

Perfect!

Traceback (most recent call last):
  File "C:\Users\HP\Desktop\opencv\scanner.py", line 3, in <module>
    from skimage.filters import threshold_adaptive
  File "C:\Users\HP\Desktop\opencv\skimage\__init__.py", line 157, in <module>
    _raise_build_error(e)
  File "C:\Users\HP\Desktop\opencv\skimage\__init__.py", line 138, in _raise_build_error
    %s""" % (e, msg))
ImportError: DLL load failed: %1 is not a valid Win32 application.
It seems that scikit-image has not been built correctly.

Your install of scikit-image appears to be broken.
Try re-installing the package following the instructions at:
http://scikit-image.org/docs/stable/install.html 

i am getting this error...can anyone please help ?

@SANCHITGITHUB

  1. Could you elaborate on why you have skimage in opencv folder?
  2. How did install opencv and skimage?
  3. What is in the script you are executing?
  1. I was learning making a scanner in which skimage is bieng used
  2. I installed it through pip install
  3. python

On Wed, Jun 28, 2017 at 4:03 PM, Egor Panfilov notifications@github.com
wrote:

@SANCHITGITHUB https://github.com/sanchitgithub

  1. Could you elaborate on why you have skimage in opencv folder?
  2. How did install opencv and skimage?
  3. What is in the script you are executing?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/scikit-image/scikit-image/issues/2440#issuecomment-311621995,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AcKd3tir-_HmuEe9lQwG4EgP99iYKB1_ks5sIiwJgaJpZM4LebRk
.

@SANCHITGITHUB it seems to me that you're executing something from C:\Users\HP\Desktop\opencv. As far as there is a C:\Users\HP\Desktop\opencv\skimage folder, it is being used for import instead of system-wide skimage installation. You should work with skimage which is properly installed (for example, via pip), as there are some Cython code which needs to be build, not the skimage just cloned from GitHub.

Try to remove skimage directory from C:\Users\HP\Desktop\opencv and run your script again. If you need to modify your local copy of skimage, you should use the one already installed (C:\Python27\...), or setup skimage in the development mode (for this run pip install -e . in skimage directory).

I just removed skimage from local directory and tried to run this code to
check

from imutils.perspective import four_point_transform
import imutils
from skimage.filter import threshold_adaptive
import numpy as np
import argparse
import cv2

it gave me the following error

Traceback (most recent call last):
File "C:UsersHPDesktopopencvscanner.py", line 3, in
from skimage.filter import threshold_adaptive
ImportError: No module named skimage.filter

What should I do now ?

On Wed, Jun 28, 2017 at 5:27 PM, Egor Panfilov notifications@github.com
wrote:

@SANCHITGITHUB https://github.com/sanchitgithub it seems to me that
you're executing something from C:UsersHPDesktopopencv. As far as
there is a C:UsersHPDesktopopencvskimage folder, it is being used
for import instead of system-wide skimage installation. You should work
with skimage which is properly installed (for example, via pip), as there
are some Cython code which needs to be build, not the skimage just cloned
from GitHub.

Try to remove skimage directory from C:UsersHPDesktopopencv and run
your script again. If you need to modify your local copy of skimage, you
should use the one already installed (C:Python27...), or setup skimage
in the development mode (for this run pip install -e . in skimage
directory).

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/scikit-image/scikit-image/issues/2440#issuecomment-311638391,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AcKd3lNc8G4gPF5Aq7WHAWIkKlZ-QUXeks5sIj-hgaJpZM4LebRk
.

@SANCHITGITHUB it explains the issue pretty clear. There is no skimage.filter module. Since recently it is renamed to skimage.filters.

At first I tried skimage.filters , it gave me the same error. Then i found
out that skimage.filter may work if my system is not updated but again it
is showing the same error.
I n screwed now.

On Thu, Jun 29, 2017 at 11:08 AM, Egor Panfilov notifications@github.com
wrote:

@SANCHITGITHUB https://github.com/sanchitgithub it explains the issue
pretty clear. There is no skimage.filter module. Since recently it is
renamed to skimage.filters.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/scikit-image/scikit-image/issues/2440#issuecomment-311867423,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AcKd3vcP3dP7CSx828jgZeSOVtbGGUi1ks5sIzhOgaJpZM4LebRk
.

@SANCHITGITHUB Please follow the installation instructions on the website step by step. If that does not work, try doing the same, but in an entirely new virtual environment (or conda environment, if that's what you're using).

I am currently getting this error. Any suggestions?

Traceback (most recent call last):
  File "/home/vagrawal38/venv/lib/python3.5/site-packages/skimage/__init__.py", line 154, in <module>
    from ._shared import geometry
ImportError: /home/vagrawal38/venv/lib/python3.5/site-packages/skimage/_shared/geometry.cpython-35m-x86_64-linux-gnu.so: undefined symbol: _PyThreadState_UncheckedGet

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 13, in <module>
    from utils import transforms as custom_transforms
  File "/home/vagrawal38/utils/transforms.py", line 7, in <module>
    from skimage import color
  File "/home/vagrawal38/venv/lib/python3.5/site-packages/skimage/__init__.py", line 157, in <module>
    _raise_build_error(e)
  File "/home/vagrawal38/venv/lib/python3.5/site-packages/skimage/__init__.py", line 138, in _raise_build_error
    %s""" % (e, msg))
ImportError: /home/vagrawal38/venv/lib/python3.5/site-packages/skimage/_shared/geometry.cpython-35m-x86_64-linux-gnu.so: undefined symbol: _PyThreadState_UncheckedGet
It seems that scikit-image has not been built correctly.

Your install of scikit-image appears to be broken.
Try re-installing the package following the instructions at:
http://scikit-image.org/docs/stable/install.html 

More info: v0.12.1 works perfectly so I am only seeing this on v0.13.3.
I am using Ubuntu 14.04.

@varunagrawal Not sure what v0.13.3 is... Try to remove completely /home/vagrawal38/venv/lib/python3.5/site-packages/skimage, and re-install the library. I assume you are using pip?

I had the same problem in RHEL6. I'm using Python3.5 (compiled and build by myself because it isn't in the repositories) and the latest version of skimage (0.13.3) using pip gives me the same error.
I tried removing everything from skimage in the virtualenv, but the error stills after reinstalling with pip.

But version 0.12.1 works perfectly :/ (I didn't try with other versions)

@Patataman If you rebuild from source, this should not happen. So I am confused, because you said you did that.

Can you try:

python -m pip uninstall scikit-image
python -m pip install -e .
python -c 'import skimage; print(skimage.__version__)'

in the source directory, and see if that succeeds and fixes the problem?

@soupault that was the version I had locally from the repo at the time. Installing the library works fine since pip has v0.13.1. There seems to be some sort of regression somewhere. I apologize for the delay in responding.

@stefanv

First of all, the version I was installing was 0.13.1 (not 0.13.3, my bad :/)
And second, what I compiled and built was Python3.5 not skimage

Install it from source like you said installs the 0.14dev version and does not have any error

Hello,
I just got a similar issue on Shippbale while using skimage for python 3.5 (somehow the same code and configuration works fine for python 3.4) and setting requirements as scikit-image>=0.12.1

Collecting scikit-image>=0.12.1 (from -r requirements.txt (line 8))
  Downloading scikit_image-0.13.1-cp35-cp35m-manylinux1_x86_64.whl (35.5MB)

The error message is following

ERROR: Failure: ImportError (/root/venv/3.5/lib/python3.5/site-packages/skimage/_shared/geometry.cpython-35m-x86_64-linux-gnu.so: undefined symbol: _PyThreadState_UncheckedGet
It seems that scikit-image has not been built correctly.

Your install of scikit-image appears to be broken.
Try re-installing the package following the instructions at:
http://scikit-image.org/docs/stable/install.html )
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/venv/3.5/lib/python3.5/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/root/venv/3.5/lib/python3.5/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/root/venv/3.5/lib/python3.5/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/root/venv/3.5/lib/python3.5/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/root/venv/3.5/lib/python3.5/imp.py", line 234, in load_module
    return load_source(name, filename, file)
  File "/root/venv/3.5/lib/python3.5/imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 693, in _load
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 662, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/root/src/github.com/Borda/pyBPDL/bpdl/dataset_utils.py", line 30, in <module>
    from skimage import io, draw, transform, filters
  File "/root/venv/3.5/lib/python3.5/site-packages/skimage/__init__.py", line 157, in <module>
    _raise_build_error(e)
  File "/root/venv/3.5/lib/python3.5/site-packages/skimage/__init__.py", line 138, in _raise_build_error
    %s""" % (e, msg))
ImportError: /root/venv/3.5/lib/python3.5/site-packages/skimage/_shared/geometry.cpython-35m-x86_64-linux-gnu.so: undefined symbol: _PyThreadState_UncheckedGet
It seems that scikit-image has not been built correctly.

Your install of scikit-image appears to be broken.
Try re-installing the package following the instructions at:
http://scikit-image.org/docs/stable/install.html 

Any suggestion?

@Borda I'm not really sure what the cause is, but this issue seems related - https://github.com/pyenv/pyenv/issues/989 .

Try this conda install -c conda-forge pillow=4.3.0
I had the same problem and this fixed it.

@malymaciel, I do not conda have shippable but while upgrading pip install -U pillow it crashes (downloading 5.x) and upgrading Cython to version 0.28 or higher did not help
@soupault may it issue with a particular wheel?

Collecting scikit-image>=0.13.0 (from -r requirements.txt (line 9))
  Downloading https://files.pythonhosted.org/packages/64/18/402284ae09b6a2a8694e707b4924a1a9573bb4aa67923cf487978555e822/scikit_image-0.13.1-cp35-cp35m-manylinux1_x86_64.whl (35.5MB)

btw, I have opened a question to Shippable - https://github.com/Shippable/support/issues/4272

Hi,
I am a newbie and trying to use a local version of the package unzipped in my linux home directory and the path appended to the sys.path but getting the following error, any help is appreciated. Thanks
`Traceback (most recent call last):
File "/net/home/h04/ssadri/my-python-modules/scikit-image-0.14.x/skimage/__init__.py", line 165, in
from ._shared import geometry
ImportError: cannot import name 'geometry'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/h04/ssadri/fcm_projects/ciid/Saeed/cvision.py", line 7, in
from skimage import data
File "/net/home/h04/ssadri/my-python-modules/scikit-image-0.14.x/skimage/__init__.py", line 168, in
_raise_build_error(e)
File "/net/home/h04/ssadri/my-python-modules/scikit-image-0.14.x/skimage/__init__.py", line 149, in _raise_build_error
%s""" % (e, msg))
ImportError: cannot import name 'geometry'
It seems that scikit-image has not been built correctly.

Your install of scikit-image appears to be broken.
Try re-installing the package following the instructions at:
http://scikit-image.org/docs/stable/install.html `

@balazagi please read the instructions at http://scikit-image.org/docs/stable/install.html. You need to install the scikit-image prerequisites (seen in requirements.txt), Cython, and you need to build the C parts of scikit-image.

thanks you for this but I was naively thinking that this maybe possible without the use of _pip_ as I don't have permission to run it. I have requested the addition of the package to the environment but that is going to take a few weeks to be approved so was hoping for a quicker solution, hence local installation!

You can use pip to install locally, see e.g. https://stackoverflow.com/questions/7143077/installing-pip-packages-to-home-folder

I also highly recommend conda, which lets you create environments in your home directory where you can install packages as if they were in your root folder. (ie pip install scikit-image will just work once you have a conda environment set up.) See: https://conda.io/miniconda.html

Conda itself can be installed without admin access.

Many Thanks Juan, I have used conda on my home machine and was able to successfully install and use this package but did not know that is possible to run _conda_ or _pip_ as a non-admin user which of course now will try!

thanks for the pointers. I was able to install both pip and the scikit-image locally :+1:

:tada:

Was this page helpful?
0 / 5 - 0 ratings