Ask Your Question
1

[solved] Sagemath Docker 10.9 fails to find python.h

asked 2026-05-10 12:08:41 +0200

Bert RAM Aerts gravatar image

updated 2026-05-16 10:57:53 +0200

With Sagemath Docker 10.9 I opened sagemath_examples.ipynb and clicked run all. It contains cython code at the end "%%cython\n", "def sum_cy(n):\n", " s = 0\n", " for i in range(n):\n", " s += i\n", " return s" This gives a large amount of errors with at the end "python.h not found". Can the docker image be updated to correct this error ?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2026-05-13 07:10:23 +0200

ortollj gravatar image

updated 2026-05-13 07:11:43 +0200

I just asked your question to Copilot, here is his answer:

This issue is caused by a missing dependency inside the official SageMath 10.9 Docker image. The last cell of the sagemath_examples.ipynb notebook uses Cython (via %%cython), which requires the Python development headers in order to compile the generated C code.

Inside the 10.9 Docker image, the file python.h is not present, which means that the corresponding package (typically python3-dev or python3.X-dev) was not installed when the image was built. As a result, any Cython cell that needs to compile C extensions will fail with the error:

fatal error: Python.h: No such file or directory

This is not a user error and not related to the notebook itself. It is a packaging issue in the Docker image: the Python headers are required for Cython examples to work, but they are currently missing.

The Docker image likely needs to be rebuilt with the appropriate Python development package installed. For example, on Debian/Ubuntu-based images, installing:

apt-get install python3-dev

(or the specific versioned package matching the Python version inside the container) would resolve the issue.

Until the image is updated, any Cython-based examples in the official notebook will fail inside the 10.9 Docker container.

edit flag offensive delete link more

Comments

1

I think we've entered a new era. We now need to use AI.

In an unpredictable era, perhaps a world resembling that of the film Soylent_Green https://en.wikipedia.org/wiki/Soylent... A world filled with unemployed people, ruled by corrupt elites with ideas flirting with the far right.Those who will own the AIs.

ortollj gravatar imageortollj ( 2026-05-13 07:23:41 +0200 )edit

Thank you for reporting and investigating the issue. It is fixed now in the latest Docker image of SageMath 10.9; see https://github.com/sagemath/sage/pull...

eric_g gravatar imageeric_g ( 2026-05-16 10:07:21 +0200 )edit
0

answered 2026-05-16 10:57:03 +0200

Bert RAM Aerts gravatar image

New docker image available and working fine.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2026-05-10 12:08:41 +0200

Seen: 80 times

Last updated: 4 hours ago