[Python] reticulate cannot bind to Python: "was not built with a shared library" even after...

Discussão em 'Python' iniciado por Stack, Abril 21, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using R with the reticulate package to run Python code. When I try to load reticulate, I get the following error:


    Error: '/usr/bin/python3.10' was not built with a shared library. reticulate can only bind to copies of Python built with '--enable-shared'.
    ​

    To fix this, I installed Miniconda using reticulate::install_miniconda() and created a new environment called basenv. Then I ran:

    use_python("/home/asma.ait/.local/share/r-miniconda/envs/basenv/bin/python", required = TRUE)


    And my py_config() looks like this:

    python: /home/asma.ait/.local/share/r-miniconda/envs/basenv/bin/python
    libpython: /home/asma.ait/.local/share/r-miniconda/envs/basenv/lib/libpython3.8.so
    pythonhome: /home/asma.ait/.local/share/r-miniconda/envs/basenv:/home/asma.ait/.local/share/r-miniconda/envs/basenv
    version: 3.8.20


    How can I ensure reticulate stops using the system Python and binds properly to the Miniconda one?

    However, even after restarting RStudio and setting this in my .Rprofile:

    Sys.setenv(RETICULATE_PYTHON = "/home/asma.ait/.local/share/r-miniconda/envs/basenv/bin/python")


    ...I still get the same error about /usr/bin/python3.10 not being built with --enable-shared.

    Continue reading...

Compartilhe esta Página