# Python 3.9 bindings

**URL:** <https://forum.orfeo-toolbox.org/t/python-3-9-bindings/1054>\
**Category:** OTB Development\
**Created:** [May 10, 2021, 7:32pm UTC](https://forum.orfeo-toolbox.org/t/python-3-9-bindings/1054 "2021-05-10T19:32:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![millionpoundhat](https://forum.orfeo-toolbox.org/user_avatar/forum.orfeo-toolbox.org/millionpoundhat/32/451_2.png) [@millionpoundhat](https://forum.orfeo-toolbox.org/u/millionpoundhat)\
**Post date:** [May 10, 2021, 7:32pm UTC](https://forum.orfeo-toolbox.org/t/python-3-9-bindings/1054/1 "2021-05-10T19:32:54Z")

</div>

Hello,

I would like to use orfeos Python bindings from Python 3.9 on Debian linux. The documentation suggests that it is possible to build the binds for a target version of Python rather than 3.5 (which is now EOL). Has anyone has success doing this? Has any hints or tips?

Can I compile the whole of orfeo-toolbox from source with a target python version?

Thanks in advance,

Ills

---

<div class="post-metadata">

**Author:** ![Cedric](https://forum.orfeo-toolbox.org/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@Cedric](https://forum.orfeo-toolbox.org/u/Cedric)\
**Post date:** [May 11, 2021, 7:17am UTC](https://forum.orfeo-toolbox.org/t/python-3-9-bindings/1054/2 "2021-05-11T07:17:37Z")

</div>

Hello,

Using the OTB binary packages, it is possible to [recompile the python bindings](https://www.orfeo-toolbox.org/CookBook/Installation.html#recompiling-python-bindings) for a specific python version:

```bash
cd OTB_DIR
source otbenv.profile
ctest -S share/otb/swig/build_wrapping.cmake -VV

```

I just tried with success on Ubuntu using python 3.9 from conda. Note that Numpy and Cmake are required.

If you wish to recompile OTB from sources, you can have a look at [this page](https://www.orfeo-toolbox.org/CookBook/CompilingOTBFromSource.html#gnu-linux-and-macos). To compile the python bindings the `OTB_WRAP_PYTHON` CMake variable should be set to `ON`, and the `PYTHON_EXECUTABLE` to the location of the python executable (if the defaut python is not used).

I hope that helps,  
Cédric

---

<div class="post-metadata">

**Author:** ![millionpoundhat](https://forum.orfeo-toolbox.org/user_avatar/forum.orfeo-toolbox.org/millionpoundhat/32/451_2.png) [@millionpoundhat](https://forum.orfeo-toolbox.org/u/millionpoundhat)\
**Post date:** [May 11, 2021, 8:55am UTC](https://forum.orfeo-toolbox.org/t/python-3-9-bindings/1054/3 "2021-05-11T08:55:14Z")

</div>

Thanks for the help Cedric,

I had tried what was detailed in the docs and as per your last message, but was getting the an error in both a debian container (python3.9:slim buster from the official docker repo) and my own Debian based (pop\_os\_20.10) system.

In both cases what I found after some investigation was that I needed to install OpenGL, using _apt-get install libgl1-mesa-dev_ did the trick. Would you accept a very small PR on the docs with this note?

Thanks,  
Ills

---

<div class="post-metadata">

**Author:** ![Cedric](https://forum.orfeo-toolbox.org/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@Cedric](https://forum.orfeo-toolbox.org/u/Cedric)\
**Post date:** [May 11, 2021, 9:45am UTC](https://forum.orfeo-toolbox.org/t/python-3-9-bindings/1054/4 "2021-05-11T09:45:49Z")

</div>

> Would you accept a very small PR on the docs with this note

Sure !

I am not sure why openGL is required here. OpenGL is required to compile the visulaization tools (Monteverdi), but it shouldn’t be required to compile the Python, I think there is something wrong in the CMake code here.

Cédric
