Home > Mobile >  Codespaces: Force python version
Codespaces: Force python version

Time:12-24

I'm having trouble installing a specific version of Python in my Github Codespace with VSCode. I don't have much experience with Docker, so this is turning into a really frustrating experience.

Here's my Dockerfile. It seems to always default to Python 3.8– how can I get it to install the latest version of 3.7?

FROM mcr.microsoft.com/vscode/devcontainers/universal:latest
RUN sudo -H pip install poetry

PostCreate.sh

#!/bin/bash

PostAttach.sh

#!/bin/bash
poetry env use /opt/python/3.7.12/bin/python <-- No idea how to install 3.7 before this
poetry install
poetry run pre-commit install
poetry shell

CodePudding user response:

I think the easiest way would be to use a base image which comes with Python 3.7:

FROM mcr.microsoft.com/vscode/devcontainers/python:3.7
RUN pip install poetry
  • Related