repl_python producing errors Reticulate

I am really struggling to get reticulate to work for me.

I ran reticulate::repl_python() and got the normal flag asking me if I wanted to set up a virtual environment. I said yes but now when I run reticulate::repl_python() I get an error:

Error: PyType_GetFlags - /usr/lib64/ undefined symbol: PyType_GetFlags
In addition: Warning message:
In py_initialize(config$python, config$libpython, config$pythonhome, :
   Python 2 reached EOL on January 1, 2020. Python 2 compatability will be removed in an upcoming reticulate relesae.

I found this Posit Communit post on a similar error and followed their advice to reinstall reticulate using devtoolsbut I am still getting the same error.

Reading the git issue chain that was linked to the Posit issue it sounded like I could use use_python to set which python instance to use and that might solve the problem. So then I ran


And I get out a giant error which then cause my R session to be aborted. Error reads:

[522345:522345:20240502,10581.255126:ERROR process] read of of range
[522345:522345:20240502,10581.255126:ERROR] missing nul-terminator
[522345:522345:20240502,10581.255126:ERROR elf_dynamic_array_reader.h:61] tag not found
[522345:522345:20240502,10581.255126:ERROR elf_dynamic_array_reader.h:61] tag not found
[522345:522345:20240502,10581.255126:ERROR] opendir: No such file or directory (2)

I am running R 4.2.1, R Studio 2023.12 on a Red Hat 8.4 server.


  1. I tried reinstalling reticulate that did not help
  2. When I run py_run_string("import sys; print(sys.version)") as a test I get the first PyType_GetFlags error as written above.

It looks like reticulate is trying to use Python 2. Python 2 is no longer supported.

Do you have a more recent version of Python 3 available? If not, you can call reticulate::install_python().

My best guess is that the second error you see will resolve if you restart the R session; attempting to bind to Python 2 may leave reticulate in an inconsistent state.