Install skimage.metrics?

I’m using anaconda (python 3.7) and skimage does not have skimage.metrics as a submodule

I know this is stupid but how do install this submodule

I’ve tried reinstalling skiimagu via bash but it doesn’t;t include the submodule I want (.metrics)

1 Like

Can you verify which version you are installing? I think the default conda package repository only has through v 0.15, which doesn’t include metrics. You can try pip installing or installing from source. Or possibly conda-forge

Yes, this is probably the issue. You can check with import skimage; print(skimage.__version__).

Hi

I’ve deinstalled and then reinstalled using conda forge as per the instructions on the skikit image website. But it reinstalls the old version!

How do I get it to install the correct version once I’ve deinstalled?

Bit new to installing packages I usually use MATLAB

Thanks

conda install -c conda-forge scikit-image or pip install scikit-image should do the trick.

It sounds like you are trying to update scikit-image in your conda base environment. Probably some of the scikit-image dependencies (e.g. numpy) installed in you base environment are old and since conda looks for compatible versions, it just installs an old version of scikit-image as well.

I strongly recommend you to create separate environments for your projects and to actually never use the base environment. You can try to create such a clean environment by typing (you can name your environment something else than myenv):

conda create -n myenv

Then activate the environment with either:

conda activate myenv

or

source activate myenv

and now install scikit-image within that environment:

conda install -c conda-forge scikit-image

Then start python and type this to check if you have the right version, which should now be 0.16.2:

import skimage
skimage.__version__

If you need to install other packages within this environment, first activate it and then use regular conda commands.

1 Like

Thanks very much for this answer.

I’m still being a bit dumb. Say I was to run my code in Spyder would I have to run it out of that new environment I created in order to get the new skimage version to work ? So I have to add that myenv filepath (?) to the root

Sorry I’m a bit confused. Like i said I usually use MATLAB so this is all a bit new to me

Thanks

@Charlie_Jeynes don’t worry, it’s not you being dumb — the Python environment and packaging situation is quite messy and definitely challenging to get your head around and work with. Even Python experts end up resorting to a scorched-earth, delete-everything-and-start-again approach on occasion.

I am not very familiar with selecting environments in Spyder, but this guide from the Spyder wiki might offer a solution:

I hope this helps!

I can only second @jni, unfortunately package management can be a mess sometimes in Python. Based on the Github solution, I think the following recipe should work for you (I’m not familiar with spyder either, so no guarantee here). Execute the following steps in a single terminal:

(1) Create a new environment: conda create -n myenv pip
(2) Activate the environment (you might need source activate instead of conda activate depending how conda is configured): conda activate myenv
(3) Install Spyder specifically in that environment: conda install -c anaconda spyder
(4) Install skimage specifically in that environment: conda install -c conda-forge scikit-image
(5) Install anything else needed in that environment using conda or pip. pip install whatever_package

I hope I won’t make this even more confusing, but an important point in (1) is to install pip. If you don’t, when you install something with pip in the environment, you might end up in trouble.

Whenever you want to use spyder, open a terminal and type:

conda activate myenv
spyder

Hi all
Thanks very much for your replies

I shall have a go and see if it works for me

Thanks

Charlie