Skip to content

Python Development Environment

Mark Millard edited this page Jun 13, 2025 · 25 revisions

This page describes how to set up the Python development environment for building Magic Lantern Python Studio.

Table of Contents

Linux Platform

These instructions may be used to set up the Python development environment for the Linux Platform. They have been tested using the Ubuntu 18.04 LTS 64-bit operating system.

Resources

Install Python

Update and upgrade your system to ensure that your shipped version of Python 3 is up-to-date.

sudo apt update
sudo apt -y upgrade

Check which version of Python 3 is installed by typing:

python3 -V

Install pip

To manage software packages for Python, install pip, a tool that will install and manage libraries or modules to use in your projects.

sudo apt install -y python3-pip

Python packages can be installed by typing:

pip3 install package_name

Install Additional Packages and Tools

There are a few more packages and development tools to install to ensure that we have a robust set-up for our programming environment:

sudo apt install build-essential libssl-dev libffi-dev python3-dev

Install Virtual Environment

See Create a Virtual Environment to setup a Python virtual environment. For example:

python3 -m venv mle-python-env

Activate Virtual Environment

To activate and use the Python3 toolchain, do the following:

source ./mle-python-env/bin/activate

Install PySide2

To use Qt for Python, you will need to install PySide2 (for Qt5 support). Do the following after activating the virtual environment:

pip install pyside2

Linux Troubleshooting

Python.h Header Not Found

If your build is having troubles finding Python.h, make sure that you have installed the autoconf-archive package (see https://www.gnu.org/software/autoconf-archive). This package installs additional AX_ macros utilized by the Python configure.ac configuration in Magic Lantern Studio.

distutils Not Found

Python v3.12 and later no longer installs distutils. Use pip to install the package setuptools to workaround this issue:

pip install setuptools

MacOS Platform

These instructions may be used to set up the Python development environment for the Macintosh OS Platform. They have been tested using the macOS Catalina (10.15.4) operating system.

Install Python

Use Installing Python 3 on Mac OS X instructions for installing Python 3.

MacOS Troubleshooting

distutils Not Found

Python v3.12 and later no longer installs distutils. Use pip to install the package setuptools to workaround this issue:

brew install python-setuptools

Windows Platform

These instructions may be used to set up the Python development environment for the Windows Platform.

Install Python

Version 3.10.11 of Python can be downloaded from here. Use this installer executable to install python.

Add the PYTHON_HOME environment variable using the location where you installed the program (e.g. C:\Users\msm\AppData\Local\Programs\Python\Python310).

Python Debug Support

The debug library is not installed by default with the standard Python installer. It requires manual selection during the installation process.