SimpleITK installation in anaconda environment

Hi all,
I hope this is a relevant question for this forum …
I am trying to install simpleITK in Anaconda3 environment. I followed the instructions in the manual.

  1. pip install SimpleITK
  2. conda list
    I can see SimpleITK is in the list of packages.

I did run this script and it did show installation is correct!

from __future__ import print_function
import importlib
from distutils.version import LooseVersion

# check that all packages are installed (see requirements.txt file)
required_packages = {'jupyter', 
                     'numpy',
                     'matplotlib',
                     'ipywidgets',
                     'scipy',
                     'pandas',
                     'SimpleITK'
                    }

problem_packages = list()
# Iterate over the required packages: If the package is not installed
# ignore the exception. 
for package in required_packages:
    try:
        p = importlib.import_module(package)        
    except ImportError:
        problem_packages.append(package)
    
if len(problem_packages) is 0:
    print('All is well.')
else:
    print('The following packages are required but not installed: ' \
          + ', '.join(problem_packages))

output: All is well
meaning the SimpleITK binaries are installed in my condo virtual environment installed.
I tried to write my first SimpleITK program to make sure it is working

import SimpleITK as sitk

%run update_path_to_download_script
from downloaddata import fetch_data, fetch_data_all

from ipywidgets import interact

print(sitk.Version())

%run update_path_do_download_script not recognized because the magic command %run is not there. therefore next line:
from download data import fetch_data, fetch_data_all
raises an error meaning downloaddata python script is not in my python path, that is SimpleITK does not have this script, I have checked SimpleITK-Notebook has download data.py in repository but I have installed binary SimpleITK.
I hope this question is relevant to the ITK forum,
any help is appreciated.

Regards,
sohrab azami

Hello @sag,

Welcome to SimpleITK!

Before you proceed any further I recommend that you skim through the SimpleITK read-the-docs. It will illustrate how to install SimpleITK and introduce the toolkit’s fundamental concepts and conventions.

To your questions:

  1. To install SimpleITK for anaconda/miniconda conda install -c simpleitk simpleitk.
  2. The errors you are encountering are due to the fact that the notebook repository has additional functionality that is outside the SimpleITK scope (downloading data from cloud storage, visualization of images in notebooks etc.). You are also using code that is intended for use in ipython and not standard Python scripts (e.g. %run magic).

You can obviously copy the relevant code from the notebook repository and use it, but these are auxiliary functions that are mostly useful if you intend to write code using Jupyter notebooks and not standalone Python scripts, or want to download the images used by the notebooks for other uses.

This will work as a Python script:

import SimpleITK as sitk
print(sitk.Version())
1 Like