# SimpleITK and Python 3.11

**URL:** https://discourse.itk.org/t/simpleitk-and-python-3-11/6234
**Category:** Engineering
**Tags:** dicom, simpleitk
**Created:** [September 26, 2023, 8:09pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234 "2023-09-26T20:09:35Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![Wallesss](https://discourse.itk.org/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@Wallesss](https://discourse.itk.org/u/Wallesss)
#### Post date: [September 26, 2023, 8:09pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/1 "2023-09-26T20:09:35Z")

</div>

Hello, the SimpleITK 1.2.4 library does not connect to the project and the error keeps appearing: ModuleNotFoundError: no module named ‘simpleitk.\_simpleitk’. Python version is 3.11. Spyder version is 5.4. When using the command prompt, a completely similar problem occurs. Link to the project - [GitHub - biomedia-mira/blast-ct: Brain Lesion Analysis and Segmentation Tool for Computed Tomography](https://github.com/biomedia-mira/blast-ct)

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [September 26, 2023, 9:01pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/2 "2023-09-26T21:01:11Z")

</div>

Hello @Wallesss,

Python 3.11 was released in 2022, SimpleITK 1.2.4 was released in 2019 so there are no SimpleITK wheels for that combination. The latest version of Python supported by the SimpleITK 1.2.4 release is Python 3.8. Bottom line, SimpleITK is not installed in the development environment.

Things to try in order of complexity:

1. Use Python 3.8 instead of 3.11 and everything will work out of the box.
2. Use Python 3.11 and hope for the best. Upgrade to SimpleITK 2.2.1 or above (2.2.1 was the first release with wheels for Python 3.11). If lucky, the original code does not need to be modified. If unlucky, evaluate the amount of code change necessary. Hope the changes are minimal.
3. Use Python 3.11, no changes to your code, and [build SimpleITK 1.2.4](https://simpleitk.readthedocs.io/en/master/building.html) locally. Create the wheel using Python 3.11.

---

<div class="post-metadata">

### Author: ![Wallesss](https://discourse.itk.org/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@Wallesss](https://discourse.itk.org/u/Wallesss)
#### Post date: [September 27, 2023, 7:45am UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/3 "2023-09-27T07:45:38Z")

</div>

I tried to create a virtual environment in spyder, but the spyder-kernels library does not work with python 3.8.

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [September 27, 2023, 5:34pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/4 "2023-09-27T17:34:43Z")

</div>

Hello @Wallesss,

Not sure what you mean by “spyder-kernels”. You can set up a virtual environment using [venv](https://docs.python.org/3/library/venv.html) for plain Python or [conda](https://docs.conda.io/projects/conda/en/stable/user-guide/getting-started.html) for the anaconda distribution. Install spyder into the virtual environment and then work there.

---

<div class="post-metadata">

### Author: ![Wallesss](https://discourse.itk.org/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@Wallesss](https://discourse.itk.org/u/Wallesss)
#### Post date: [September 27, 2023, 5:54pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/5 "2023-09-27T17:54:26Z")

</div>

1. I created a virtual environment using the command _‘conda create --name envspy’_. 2) Activated the environment - _‘conda activate envspy’_. 3) Installed the necessary libraries - _‘conda install spyder-kernels python=3.8.10’_ and some others. 4) I received an error in the screenshot - [d9c37b0408219277bc361d771f24056a.png hosted at IMGTR - IMGTR](https://imgtr.ee/image/RGrwU)

---

<div class="post-metadata">

### Author: ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)
#### Post date: [September 27, 2023, 5:55pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/6 "2023-09-27T17:55:49Z")

</div>

FYI, I was able to create a python virtual environment using anaconda, install spyder via conda, and install SimpleITK 1.2.4 using pip.

Then I launched spyder, and in spyder my SimpleITK test code worked.

Looking at your conda create, maybe try setting python=3.8.

---

<div class="post-metadata">

### Author: ![Wallesss](https://discourse.itk.org/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@Wallesss](https://discourse.itk.org/u/Wallesss)
#### Post date: [September 27, 2023, 5:59pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/7 "2023-09-27T17:59:28Z")

</div>

It turns out that the virtual environment does not work because _‘python=3.8.10’_ was specified rather than _‘python=3.8’_. I understand correctly? Spyder IDE was installed using an exe file.

---

<div class="post-metadata">

### Author: ![Wallesss](https://discourse.itk.org/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@Wallesss](https://discourse.itk.org/u/Wallesss)
#### Post date: [September 27, 2023, 6:11pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/8 "2023-09-27T18:11:28Z")

</div>

“spyder-kernels” is mentioned in this video - [https://youtu.be/i7Njb3xO4Fw?t=96](https://youtu.be/i7Njb3xO4Fw?t=96)

---

<div class="post-metadata">

### Author: ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)
#### Post date: [September 27, 2023, 6:13pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/9 "2023-09-27T18:13:31Z")

</div>

No, I think when you initially create the environment, you need to specify the python version. Here’s how I create my environment:

```
conda create -n spyder python=3.8
conda activate spyder
conda install spyder
pip install simpleitk==1.2.4

spyder # launch spyder

```

What you’ve done is to create a python environment with the default python version (probably 3.11), and then tried to install the py3.8 version of Spyder-kernels into it, which won’t work.

---

<div class="post-metadata">

### Author: ![Wallesss](https://discourse.itk.org/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@Wallesss](https://discourse.itk.org/u/Wallesss)
#### Post date: [September 27, 2023, 6:17pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/10 "2023-09-27T18:17:35Z")

</div>

What is “conda install spyder”? Will a second Spyder IDE be installed on my computer?

---

<div class="post-metadata">

### Author: ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)
#### Post date: [September 27, 2023, 6:20pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/11 "2023-09-27T18:20:26Z")

</div>

Yes, that is the way I installed spyder. I did it within the conda environment to ensure that I was getting the python version that I wanted.

---

<div class="post-metadata">

### Author: ![Wallesss](https://discourse.itk.org/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@Wallesss](https://discourse.itk.org/u/Wallesss)
#### Post date: [September 27, 2023, 6:20pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/12 "2023-09-27T18:20:40Z")

</div>

Will I be able to connect the environment created using your method to the Spyder IDE, as shown in this video? Link to video - [https://youtu.be/i7Njb3xO4Fw?t=96](https://youtu.be/i7Njb3xO4Fw?t=96)

---

<div class="post-metadata">

### Author: ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)
#### Post date: [September 27, 2023, 6:22pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/13 "2023-09-27T18:22:04Z")

</div>

It should be able to. When I type in spyder, it launches the IDE.

---

<div class="post-metadata">

### Author: ![Wallesss](https://discourse.itk.org/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@Wallesss](https://discourse.itk.org/u/Wallesss)
#### Post date: [September 27, 2023, 6:23pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/14 "2023-09-27T18:23:24Z")

</div>

But I already downloaded and installed Spyder IDE 5.4 from offline installers. Do I need to remove the currently installed Spyder IDE? Thanks for the dialogue.

---

<div class="post-metadata">

### Author: ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)
#### Post date: [September 27, 2023, 7:01pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/15 "2023-09-27T19:01:21Z")

</div>

You can remove that other Spyder if you want to. It probably is a good idea to keep things clean.

---

<div class="post-metadata">

### Author: ![Wallesss](https://discourse.itk.org/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@Wallesss](https://discourse.itk.org/u/Wallesss)
#### Post date: [September 29, 2023, 1:49pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/16 "2023-09-29T13:49:06Z")

</div>

Can I install additional libraries using pip, such as torch, numpy, tensorflow, tensorboard?

---

<div class="post-metadata">

### Author: ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)
#### Post date: [September 29, 2023, 1:51pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/17 "2023-09-29T13:51:36Z")

</div>

Yes, you can pip install any packages and they will get installed into the currently active anaconda environment.

---

<div class="post-metadata">

### Author: ![Wallesss](https://discourse.itk.org/letter_avatar_proxy/v4/letter/w/51bf81/32.png) [@Wallesss](https://discourse.itk.org/u/Wallesss)
#### Post date: [September 29, 2023, 1:57pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/18 "2023-09-29T13:57:42Z")

</div>

That is, I can easily connect _torch_ in code written in _Spyder IDE_, which will be installed with the command _“conda install spyder”_?

---

<div class="post-metadata">

### Author: ![dchen](https://discourse.itk.org/user_avatar/discourse.itk.org/dchen/32/34_2.png) [@dchen](https://discourse.itk.org/u/dchen)
#### Post date: [September 29, 2023, 2:01pm UTC](https://discourse.itk.org/t/simpleitk-and-python-3-11/6234/19 "2023-09-29T14:01:03Z")

</div>

Yes, you will have to restart the python kernel, I think, then torch will be available. Or you can restart the whole Spyder IDE.
