Python
Python is a popular, high-level programming language that is widely used in a variety of fields. It is known for its simplicity, readability, and flexibility, as well as its large standard library and active developer community.
Using Python in Codesphere
Python 3.8 comes pre-installed in all workspaces. The easiest way to get started with Python in Codesphere is to create a workspace from the Hello, Python!
template. This template contains a ready to run Flask app. Once provisioned head over to CI-Pipeline, run the prepare stage and, once completed, the run stage.
Changing the Python version in Codesphere
Pyenv is pre-installed in all workspaces and can be used to install other versions of Python. If you want to persistently change the version, i.e. across workspace restarts or for off-when-unused workspaces, you need to follow the steps described below.
These are the steps:
- Set
PYENV_ROOT
to/home/user/app/.pyenv
via setup/env vars - Open a new terminal (existing terminals don't get updated env vars)
- Type
pipenv install --python 3.9.0
(or any other Python version) - Or alternatively add
PIPENV_YES=1 pipenv install --python 3.9.0
to your CI prepare stage - Activate with
pipenv shell
Important note for Micro and Free workspaces: following the previous steps may lead to the terminal/pipeline being killed halfway through - this is because the installation of CPython versions tends to exceed the compute and storage in these workspaces. Current alternatives are using a pypy version of your target Python version (list available versions via: pyenv install --list | grep -i pypy
- use non-src versions) or if that is incompatible with some of your packages upgrade to a bigger workspace plan.
To work with a pypy Python version follow these steps:
- Install with
pyenv install pypy3.9-7.3.8
- replace last part with your target version - Create a pipenv with
pipenv --python /home/user/app/.pyenv/versions/pypy3.9-7.3.8/bin/python3.9
- replace last part with your target version - Activate with
pipenv shell
Explore our Python Tutorials
- Create your own voice assistant
- Create your own chatbot
- Visualizing color spaces of images with Matplotlib
- Scrape your first website with Python
- Create a Discord bot in minutes
- Creating your first neural network with TensorFlow in Python
- Build a stock trading bot with Python
- Deploy web based data visualizations with Bokeh in Python