Using Python 3.12 in Repls

I want to use the latest version of Python, 3.12b3, which has some very cool new features. However, it seems that the default template is still Python 3.10 and hasn’t been updated for a while. How can I configure my Repl in order to use this specific version (and later versions whenever I update)?

1 Like

Hi @SocietasLittera thanks for your post.

Python 3.12 is in beta at present. I used NixOS Search guidance to try and get it working in a Blank Repl but hit some issues. I don’t think it’s supported in Nix yet, therefore you won’t be able to use it in a Repl.

However I was able to get Python 3.11 working without issue. You can start a Blank Repl and then change the file replit.nix to:

{ pkgs }: {
    deps = [
        pkgs.python311
    ];
}

and the .replit file to:

run = "python main.py"

[nix]
channel = "stable-22_11"
2 Likes

What do I need to put in .replit and replit.nix files (or whatever) in order to get the behaviours of the official 3.10 template (i.e. packages auto-installer, debugger, etc.)?

2 Likes

I would copy the contents of the files from a blank Repl using the official Python template, then change the version to pkgs.python311.

1 Like

I tried replacing every instances of 3.10 to 3.11 and got the following errors:

exec: "python3": executable file not found in $PATH
Error: prybar-python311 not found in $PATH

Running echo $PATH results in a lengthy message which also ends with error: attribute 'prybar-python311' missing. This seems to mean that there’s no prybar support for Python 3.11, or at least not with the same naming scheme. Here’s a direct link, in case you need it.

While you are at it, may I ask why is there no official 3.11 template? It surely helps having access to latest (stable) features, no?

2 Likes

Question, do you need prybar? All that really is is the interpreter in the Console tab. If not, remove the lines that include the phrase “prybar-python311” from your replit.nix file.

2 Likes

I didn’t even know what prybar is until today when I searched for it on GitHub. There are two prybar in my Repl, one of those being this:

[interpreter]
  [interpreter.command]
  args = [
    "stderred",
    "--",
    "prybar-python311",
    "-q",
    "--ps1",
    "\u0001\u001b[33m\u0002\u0001\u001b[00m\u0002 ",
    "-i",
  ]
  env = { LD_LIBRARY_PATH = "$PYTHON_LD_LIBRARY_PATH" }

The other is PRYBAR_PYTHON_BIN = "${pkgs.replitPackages.prybar-python310}/bin/prybar-python311"; in the replit.nix file.

What should I do with them? I tried removing both, but I got a complaint saying no interpreter configured for this repl (as expected, I think?).

2 Likes

You should remove that whole [interpreter] section from .replit, and the prybar lines from replit.nix. Then, run kill 1 in the Shell tab to force a repl reboot.

2 Likes

Now there’s no error (thanks a lot), but there’s no package auto-installer either.

3 Likes