I want to create a codespace for python development with some post commands like: creating a conda environment activate it installing ipkyernel and creating a kernel install requirements.txt
However when I rebuild the container I dont have any error, and when I open the codespace terminal and type conda env list, only thing I see is the base environment
I tried both ways:
- Put many commands on the same postCreateCommand
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:0-3.11",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/anaconda:1": {}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "conda create --name ForecastingSarimax && conda activate ForecastingSarimax",
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"streetsidesoftware.code-spell-checker"
]
}
}
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
- Or create a .sh script with the commands and execute it
#!/usr/bin/env bash
conda create --name ForecastingSarimax
conda activate ForecastingSarimax
conda install pip
conda install ipykernel
python -m ipykernel install --user --name ForecastingSarimaxKernel311 — display-name "ForecastingSarimaxKernel311"
pip3 install --user -r requirements.txt
What am I missing here to have my requirements met? A custom environment with my pip packages and a custom kernel