canonical / canonical/python-rock

First import in the interpreter always fails in python 3.13

Open
#36 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
11
Forks
7
PR merge metrics
No merged PRs in 30d

Description

Hi!

I've tried to play with the interpreter from the `python:3.13-25.04_stable` image, but it seems that whatever I do the first import always fails.
If I import something again, then it just works.

I think it might be due to the REPL change that was part of python 3.13 [PEP](https://peps.python.org/pep-0762/) and [changelog](https://docs.python.org/3/whatsnew/3.13.html#a-better-interactive-interpreter)

Here is a quick reproducer:
```
❯ podman run -ti -u 1000 --rm docker.io/ubuntu/python:3.13-25.04_stable exec -ti /usr/bin/python3.13
Python 3.13.3 (main, Aug 14 2025, 11:53:40) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
ModuleNotFoundError: No module named '_pyrepl'
>>> os.path
Traceback (most recent call last):
File "", line 1, in
os.path
^^
NameError: name 'os' is not defined. Did you forget to import 'os'?
>>> import os
>>> os.path

>>>
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.