alnoda-workspaces/workspaces/python-workspace
2023-07-08 18:26:55 +00:00
..
workspace Upd. using wrk 2023-07-05 15:36:02 +00:00
Dockerfile Upd. using wrk 2023-07-05 15:36:02 +00:00
README.md readmes updated 2023-07-08 18:26:55 +00:00
settings.json prep for release 4.0 (alnoda-wrk) 2022-09-17 08:23:45 +00:00

Python workspace

Portable isolated containerized development environment for Python projects.

Start

docker run --name space-1 -d -p 8020-8040:8020-8040 --restart=always alnoda/python-workspace

open localhost:8020 in browser.

Features

Alnoda docs
Alnoda Hub

Pyenv

pyenv is used to isolate Python versions. For example, you may want to test your code against Python 2.7, 3.6, 3.7 and 3.8, so you'll need a way to switch between them.

List python versions

pyenv install --list

Install additional python versions

pyenv install 3.10.4
pyenv install  3.6.0
pyenv install 3.10.7

Check installed python versions

pyenv versions

Change global python version

pyenv global 3.10.4

Check python version

python --version

Create folder with local python environment, check Python version

mkdir test-pyenv
cd test-pyenv
pyenv local 3.6.0
python --version

If you want to schedule script (with Cronicle) that uses pyenv, add eval "$(pyenv init -)" before the script. For example eval "$(pyenv init -)"; python /home/project/scripts/script.py

Poetry

Create our project

poetry new poetry-demo
cd poetry-demo

Specify dependencies in pyproject.toml.

By default, poetry creates a virtual environment. There are several ways to run commands within this virtual environment. To run your script simply use poetry run

poetry run python your_script.py

The easiest way to activate the virtual environment is to create a new shell with poetry shell

poetry shell 

If you want to use another python version (installed with pyenv):

poetry env use python3.10.4