Error with scikit-image

I am an undergraduate student in computer science.Currently i am working on scikit-image.i am trying to run would like to ask you how can i fix this error.(Traceback (most recent call last):
File “/home/xarisis/PycharmProjects/scikit-image/skimage/segmentation/”, line 11, in
from …util import img_as_float
ValueError: attempted relative import beyond top-level package)

.I am using pycharm with python 3.7 on ubuntu 19.04 also using the latest scikit image version.Thanks in advance.

How have you installed everything? Through Anaconda? I’ve had issues in the past where Anaconda environments aren’t set up correctly and use the wrong Python or package version. I’m also not entirely sure how pycharm interacts with that but other editors have been known to use other paths also.

Can you copy the entire error, including traceback for people to see?

not through anaconda.Yes of course i can.—>traceback (most recent call last):
File “/home/xarisis/PycharmProjects/scikit-image/skimage/segmentation/”, line 11, in
from …util import img_as_float
ValueError: attempted relative import beyond top-level package

Thank your for the brief reply Nelson

So… you appear to be working from inside a copy of scikit-image. Is there a reason for this?

I would normally expect you to have install scikit-image into your environment/path/etc. and then your own files to be elsewhere, e.g. a git repo. Then you wouldn’t be importing from a folder that’s a directory higher than your file (which I believe is what the issue is about).

Two solutions that come to mind. One, don’t work from inside scikit-image (unless your trying to directly modify the module). Two, use sys.addpath but add the absolute path not the relative path (which it looks like you’ve tried).

Do either of those help?


The thing is that i need to modify this code.So i took the git adress and put it on pycharm so i opened the whole project there.What do you mean by absolute path?Thanks Chas

Okay then, so in that case, have you installed in developer mode?:

Try that first but if it doesn’t work you can use the sys.path.insert function to add the path to the file you’re trying to import. But instead of using .. use \home\xarisis\PyCharmProjects\scikit-image… although now I write that out it sounds like a very bad way to solve this problem!

No i havent.Which path should i use here?—> pip install -e .The \home\xarisis\PyCharmProjects\scikit-image?

So the pip -e and path things are two different solutions.

To do the pip -e version you should set your environment up as usual, navigate (in the terminal) to your downloaded scikit-image folder and use pip -e install . (where the . means ‘this folder’); actually this seems to be detailed on scikit-image’s github page and in their install.RST file ( Then, before making any changes confirm that scikit-image works using some of their examples and such.

Then, you should be able to make edits to the function as you wish.

so now i can modify the code chas?

Edit:it keep throwing the same error

I believe so. But please run some example codes first to make sure it works.

Are you running an example code with the non-edited version first to check that works? If that doesn’t work then something is incorrectly set up elsewhere.

Yes this is the non-edited version.

I also tried that but it dont seems to work

Well that seems to imply something else is wrong, if their own un-edited codes aren’t working.
Erm, and without knowing how you’re systems been set-up I’m a little at a loss…

Honestly, might be worth uninstalling every version of scikit image (see and making sure it’s completely gone from your system. Then set-up a new environment and follow the development instructions.

After that, no idea sorry.

Thanks for your help Chas.I will try to figure out whats going for a little longer and then i will try to uninstall and install it again

I think the issue here is the way you’re trying to run the file from the command line. I can’t see from your images but does that file you’re calling on the command line have a __main__ section?

Have you tried running it as a module?
Briefly, this would look like
python -m