Changing Python Version in an Elixir Native Environment

TLDR: It seems that I can’t change the Python version via PYTHON_VERSION env var in an Elixir Native Environment. Ideas? Thanks!


Greetings renderers? renderererers? rendererererers! So, after searching far and wide, wide and far, …anyways.

I’m having trouble changing the Python version in an Elixir Native Environment.

I’m able to switch Elixir/Erlang versions properly with the ELIXIR_VERSION and ERLANG_VERSION environment variables, but PYTHON_VERSION doesn’t seem work. I’ve tried setting it to 3.8.2 per Specifying a Python Version | Render as well as 3.10.5 from reports that that works, albeit in a Python Native Environment.

I also found this feature request (I’m also using Elixir/Erlang + erlport + python scripts/libraries):

It now seems that python3-pip is included and I can use it via the pip3 command. Butt I’m unable to change the version via the env var. Running python3 --version in my deployment build.sh bash script prints this no matter what PYTHON_VERSION is set:

Python 3.7.3

Is this just not possible yet in the Elixir Native Environment? Is it time to use that thing with the big ocean fish? Am I doing something wrong? What is the meaning of…sorry, maybe too many questions.

Many of those thanks things in advance, renderererererererers!

Did you find finally a solution for this? I am having the same needed, and it is been very hard to find a workaround.

My environment is:

  • Node app (node env)
  • Needed for Python 3.8 (but render.com node env, has only 3.7, I have not been able to change it with env variable, neither upgrade via commands, neither using docker for running python 3.8)

Any help? Thanks a lot

@John_McClane not for an Elixir Native Environment, but in the end I just ended up using Docker. It’s a bit of extra work but I’m able to successfully install/use the Python version I need with the official Elixir Docker image. Should be conceptually similar with Node.

Here’s my dockerfile in case it helps anyone:

FROM elixir:1.13.4-otp-25

# Install python/pip
ENV PYTHONUNBUFFERED=1
RUN apt-get update
# Install python and
# openssh-server is so render.com can support SSH connections for scp disk access and
# screen so we can use it to keep ssh sessions alive
RUN apt-get -y install python3=3.9.2-3 python3-pip python3.9-venv openssh-server screen
# RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade pip setuptools

# create the app user
RUN addgroup --system app && adduser --ingroup app --home /home/app --shell /bin/sh app

# create the appropriate directories
ENV HOME=/home/app
ENV APP_HOME=/home/app/hubspot
RUN mkdir $APP_HOME
# Setup empty ~/.ssh directory
RUN mkdir $HOME/.ssh
WORKDIR $APP_HOME

# Copy project
COPY . $APP_HOME

# chown all the files to the app user
RUN chown -R app:app $APP_HOME && chown -R app:app $HOME/.ssh && chmod 700 $HOME/.ssh

# change to the app user
USER app

# Verify write access to the .ssh folder
RUN touch $HOME/.ssh/foobar.txt

# Run build
RUN ./build.sh

# FYI: I replaced the original content below with `someappfolder` and `appname` 
CMD ["/home/app/someappfolder/_build/prod/rel/appname/bin/appname", "start"]
EXPOSE 3000

Cheers!

Hi mwu, thanks a lot for your feedback and sample code for a solution.

It still dont convince for my case (I need python just for building a file in my build stage). Finally I have decided to use a python environment, generate the file, push to s3 bucket, and then my node project can read it from the bucket (still another overengineered solution).

I still would like to know if python could be upgraded, would solve this problem so easily…

Sure thing!

I don’t think Docker adds too much complexity, and as a bonus it’ll allow you to completely customize for what you need and allow portability between services that support Docker, including your local machine.

It’ll also keep everything contained within Render instead of relying also on AWS.

Though yes, maybe add a feature request here: Feature Requests | Render