scikit-image / scikit-image

Image processing in Python
https://scikit-image.org
Other
6.04k stars 2.22k forks source link

Problem importing skimage after compiling from source #1480

Closed pierreroudier closed 9 years ago

pierreroudier commented 9 years ago

Hi,

Newbie here so I might be missing something obvious,

I installed from source an compiled against the latest trunk version using pip install ., and after installing requirements using pip install -r requirements.txt as advised, but can't seem to load the modules succesfully in ipython:

In [1]: from skimage import io
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/usr/local/src/scikit-image/<ipython-input-1-08d2254c9914> in <module>()
----> 1 from skimage import io

/usr/local/src/scikit-image/skimage/io/__init__.py in <module>()
      5 """
      6 
----> 7 from .manage_plugins import *
      8 from .sift import *
      9 from .collection import *

/usr/local/src/scikit-image/skimage/io/manage_plugins.py in <module>()
     25 from glob import glob
     26 
---> 27 from .collection import imread_collection_wrapper
     28 
     29 

/usr/local/src/scikit-image/skimage/io/collection.py in <module>()
     12 from PIL import Image
     13 
---> 14 from ..external.tifffile import TiffFile
     15 
     16 

/usr/local/src/scikit-image/skimage/external/tifffile/__init__.py in <module>()
      2     from tifffile import imread, imsave, TiffFile
      3 except ImportError:
----> 4     from .tifffile_local import imread, imsave, TiffFile

/usr/local/src/scikit-image/skimage/external/tifffile/tifffile_local.py in <module>()
    152 import numpy
    153 
--> 154 from . import _tifffile
    155 
    156 __version__ = '0.3.3'

ImportError: cannot import name _tifffile

Surprising given I've installed skimage successfully on a very similar config a few weeks back. Any pointers would be appreciated.

jni commented 9 years ago

It looks like the tifffile.c module (which we ship, it's not part of the requirements) was not compiled properly. Can you provide details of how you installed it?

JDWarner commented 9 years ago

This can also be caused by an out of date Cython. Try updating Cython with

pip install -U cython

Then recompile.

On Wednesday, April 29, 2015, Juan Nunez-Iglesias notifications@github.com wrote:

It looks like the tifffile.c module (which we ship, it's not part of the requirements) was not compiled properly. Can you provide details of how you installed it?

— Reply to this email directly or view it on GitHub https://github.com/scikit-image/scikit-image/issues/1480#issuecomment-97311834 .

pierreroudier commented 9 years ago

@jni :

The procedure I used is the one documented on the website:

I'm running Python 2.7 (old version which I need for another piece of software in my workflow) on (X)Ubuntu 12.04.2 LTS (64 bits).

@JDWarner :

Good point, I successfully updated cython to 0.22 using sudo pip install -U cython as advised. The output of the skimage re-compilation shows:

Unpacking /usr/local/src/scikit-image
  Running setup.py egg_info for package from file:///usr/local/src/scikit-image
    Compiling /tmp/pip-lGCyhm-build/skimage/_shared/geometry.pyx because it changed.
    Cythonizing /tmp/pip-lGCyhm-build/skimage/_shared/geometry.pyx
   [...]
    Compiling /tmp/pip-lGCyhm-build/skimage/segmentation/_slic.pyx because it changed.
    Cythonizing /tmp/pip-lGCyhm-build/skimage/segmentation/_slic.pyx
    build_src
    building extension "skimage._shared.geometry" sources
    building extension "skimage._shared.transform" sources
    building extension "skimage.draw._draw" sources
    building extension "skimage.feature.corner_cy" sources
    building extension "skimage.feature.censure_cy" sources
    building extension "skimage.feature.orb_cy" sources
    building extension "skimage.feature.brief_cy" sources
    building extension "skimage.feature._texture" sources
    building extension "skimage.feature._hessian_det_appx" sources
    building extension "skimage.restoration._unwrap_1d" sources
    building extension "skimage.restoration._unwrap_2d" sources
    building extension "skimage.restoration._unwrap_3d" sources
    building extension "skimage.restoration._denoise_cy" sources
    building extension "skimage.restoration._nl_means_denoising" sources
    building extension "skimage.filters._ctmf" sources
    building extension "skimage.filters.rank.core_cy" sources
    building extension "skimage.filters.rank.generic_cy" sources
    building extension "skimage.filters.rank.percentile_cy" sources
    building extension "skimage.filters.rank.bilateral_cy" sources
    building extension "skimage.future.graph._ncut_cy" sources
    building extension "skimage.graph._spath" sources
    building extension "skimage.graph._mcp" sources
    building extension "skimage.graph.heap" sources
    building extension "skimage.io._plugins._colormixer" sources
    building extension "skimage.io._plugins._histograms" sources
    building extension "skimage.measure._ccomp" sources
    building extension "skimage.measure._find_contours_cy" sources
    building extension "skimage.measure._moments_cy" sources
    building extension "skimage.measure._marching_cubes_cy" sources
    building extension "skimage.measure._pnpoly" sources
    building extension "skimage.morphology._watershed" sources
    building extension "skimage.morphology._skeletonize_cy" sources
    building extension "skimage.morphology._convex_hull" sources
    building extension "skimage.morphology._greyreconstruct" sources
    building extension "skimage.transform._hough_transform" sources
    building extension "skimage.transform._warps_cy" sources
    building extension "skimage.transform._radon_transform" sources
    building extension "skimage.segmentation._felzenszwalb_cy" sources
    building extension "skimage.segmentation._quickshift" sources
    building extension "skimage.segmentation._slic" sources
    building extension "skimage.external.tifffile._tifffile" sources
    building data_files sources
    build_src: building npy-pkg config files

    warning: no files found matching 'setup.cfg'
    no previously-included directories found matching 'doc/build'
    no previously-included directories found matching 'doc/gh-pages'
Requirement already satisfied (use --upgrade to upgrade): cython>=0.21 in /usr/local/lib/python2.7/dist-packages (from scikit-image==0.12dev)
Requirement already satisfied (use --upgrade to upgrade): matplotlib>=1.1.0 in /usr/lib/pymodules/python2.7 (from scikit-image==0.12dev)
Requirement already satisfied (use --upgrade to upgrade): six>=1.3 in /usr/local/lib/python2.7/dist-packages (from scikit-image==0.12dev)
Requirement already satisfied (use --upgrade to upgrade): networkx>=1.8 in /usr/local/lib/python2.7/dist-packages (from scikit-image==0.12dev)
Requirement already satisfied (use --upgrade to upgrade): pillow>=1.7.8 in /usr/local/lib/python2.7/dist-packages (from scikit-image==0.12dev)
Requirement already satisfied (use --upgrade to upgrade): decorator>=3.4.0 in /usr/local/lib/python2.7/dist-packages (from networkx>=1.8->scikit-image==0.12dev)
Cleaning up...

Unfortunately, it seems I still have the problem when loading skimage modules in ipython:

IPython 0.12.1 -- An enhanced Interactive Python.

In [1]: from skimage import graph, data, io, segmentation, color
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/usr/local/src/scikit-image/<ipython-input-1-71952b3802d9> in <module>()
----> 1 from skimage import graph, data, io, segmentation, color

/usr/local/src/scikit-image/skimage/graph/__init__.py in <module>()
----> 1 from .spath import shortest_path
      2 from .mcp import MCP, MCP_Geometric, MCP_Connect, MCP_Flexible, route_through_array
      3 
      4 
      5 __all__ = ['shortest_path',

/usr/local/src/scikit-image/skimage/graph/spath.py in <module>()
      1 import numpy as np
----> 2 from . import _spath
      3 
      4 
      5 def shortest_path(arr, reach=1, axis=-1, output_indexlist=False):

ImportError: cannot import name _spath

Thanks for your help,

jni commented 9 years ago

Clutching at straws here, but your IPython version is pretty ancient... Do you get the same error in the Python prompt? I'm suspecting a relative import Python 2->3 incompatibility somewhere...

stefanv commented 9 years ago

After updating Cython, please run git clean -xdf in the scikit-image source directory and try the pip install again.

pierreroudier commented 9 years ago

@jni I do get the same error in the Python prompt. Pretty ancien version of iPython indeed, but I got skimage to work in this version on my laptop. @stefanv I ran git clean -xdf in my scikit-image repo, the sudo pip install.. The output of the compilation is the same, except I have a warning:

warning: no files found matching 'setup.cfg'

I still have the same error trying to load the skimage modules after compilation.

blink1073 commented 9 years ago

@pierreroudier, perhaps try removing the entire scikit-image directory and starting over? You can install it all in one go with pip install git+https://github.com/scikit-image/scikit-image (this will install directly into your site-packages).

JDWarner commented 9 years ago

@pierreroudier This has been open for a couple months without comment so I'm closing the outstanding Issue, but please feel free to reopen if necessary.

Rachine commented 8 years ago

Hi everyone, I am facing the same issue as above.

I'm running it with Python 2.7 and Ubuntu 14.04.1 LTS (64 bits). I tried the advices of this thread, but it is not working for me. There is still some problems of loading : I am trying to use the new function "seam carving" on the dev branch of scikit image. I can not import transform, it is missing shared.geometry for instance.

And it is also failing test for other imports. Does anyone managed to solve this issue. Maybe I am missing something, sorry...

alexdesiqueira commented 8 years ago

Hi all, same issue here on a Debian, Anaconda Python 3.5.

jaguar@pepperoni:~/Dropbox/git-repos/scikit-image$ make coverage
nosetests skimage --with-coverage --cover-package=skimage
E
======================================================================
ERROR: Failure: 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 )
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jaguar/Dropbox/git-repos/scikit-image/skimage/__init__.py", line 153, in <module>
    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/jaguar/anaconda3/lib/python3.5/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/home/jaguar/anaconda3/lib/python3.5/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/jaguar/anaconda3/lib/python3.5/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/jaguar/anaconda3/lib/python3.5/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/jaguar/anaconda3/lib/python3.5/imp.py", line 244, in load_module
    return load_package(name, filename)
  File "/home/jaguar/anaconda3/lib/python3.5/imp.py", line 216, in load_package
    return _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 "/home/jaguar/Dropbox/git-repos/scikit-image/skimage/__init__.py", line 156, in <module>
    _raise_build_error(e)
  File "/home/jaguar/Dropbox/git-repos/scikit-image/skimage/__init__.py", line 137, 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 

Name                 Stmts   Miss Branch BrPart  Cover   Missing
----------------------------------------------------------------
skimage/_shared.py       0      0      0      0   100%   
----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (errors=1)
Makefile:19: recipe for target 'coverage' failed
make: *** [coverage] Error 1

Installed geometry (pip install geometry) but the error is still there. Thanks for any help.

soupault commented 8 years ago

@alexandrejaguar did you perform python setup.py build_ext -i before that?

alexdesiqueira commented 8 years ago

@soupault no I didn't, sorry. I tried that and it worked! Thanks!