Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest reticulate not working with pyenv on ubuntu #1758

Closed
rundel opened this issue Mar 4, 2025 · 1 comment · Fixed by #1759
Closed

Latest reticulate not working with pyenv on ubuntu #1758

rundel opened this issue Mar 4, 2025 · 1 comment · Fixed by #1759

Comments

@rundel
Copy link

rundel commented Mar 4, 2025

I've been using a docker image with a python environment managed by pyenv and I've been able to successfully point reticulate at the shim for the last year or so. I've recently gone to update the image which brought in the new version of reticulate which is now failing when attempting to select the shim via use_python().

> reticulate::use_python("/root/.pyenv/shims/python")
Error in prefix_python_lib_to_ld_library_path(python) : 
  object 'oldlibpath' not found

I am not sure what version of reticulate we were using previously but this is behavior is new as of the last month or so.

For debugging purposes I've put together a simplified Dockerfile with replicates the environment on my end.

FROM ubuntu:24.04

ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV DEBIAN_FRONTEND noninteractive
ENV TZ UTC

RUN apt-get update \
 && apt-get upgrade -y \
 && apt-get install -y locales

RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
 && locale-gen en_US.utf8 \
 && /usr/sbin/update-locale LANG=en_US.UTF-8

ENV HOME "/root"
WORKDIR ${HOME}
RUN apt-get install -y git aria2 curl wget build-essential \
 && apt-get install -y build-essential zlib1g-dev libncurses5-dev \
                       libgdbm-dev libnss3-dev libssl-dev \
                       libreadline-dev libffi-dev wget
#RUN git clone --depth=1 https://github.com/pyenv/pyenv.git .pyenv
RUN curl https://pyenv.run | bash
ENV PYENV_ROOT "${HOME}/.pyenv"
ENV PATH "${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}"

ENV PYTHON_CONFIGURE_OPTS "--enable-shared"
ENV PYTHON_VERSION 3.12.8
RUN pyenv install ${PYTHON_VERSION}
RUN pyenv global ${PYTHON_VERSION}

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
       r-base \
       r-base-dev \
    && chown root:staff "/usr/local/lib/R/site-library" \
    && chmod g+ws "/usr/local/lib/R/site-library"

RUN Rscript -e "install.packages('reticulate', repos='https://packagemanager.rstudio.com/all/__linux__/noble/latest')"

RUN apt-get clean \
 && rm -rf /var/lib/apt/lists/*

CMD ["bash"]

To build and run:

docker build . --tag test:latest
docker run -it --rm test:latest

and once running:

Rscript -e "reticulate::use_python('/root/.pyenv/shims/python')"
@t-kalinowski
Copy link
Member

Thanks for the excellent bug report. This is now fixed in the development version.

RUN Rscript -e "install.packages('remotes', repos='https://packagemanager.rstudio.com/all/__linux__/noble/latest')"
RUN Rscript -e 'remotes::install_github("rstudio/reticulate")'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants