Python
Getting Started with Python in ExCL with best practice recommendations.
Last updated
Was this helpful?
Getting Started with Python in ExCL with best practice recommendations.
Last updated
Was this helpful?
This page covers a few recommendations and tips for getting started with Python in ExCL following best practices for packaging python projects and using virtual environments. There are many different ways to structure and package python projects and various tools that work with python, so this page is not meant to be comprehensive but to provide a few recommendations for getting started.
Using virtual environments is the recommended way to isolate Python dependencies and ensure compatibility across different projects. Virtual environments prevent conflicts between packages required by different projects and simplify dependency management. The goal with isolated, project specific python environments is to avoid the situation found in .
This pvenv
function is already configured system wide for fish on ExCL systems.
To create the virtual environment without using the wrapper function is also easy.
In bash:
In fish:
The virtual environment can be exited with deactivate
.
Steps to use the template:
Run setup_template.sh
to setup the template for the new project.
Remove setup_template.sh
For example:
Use the command below to see the available python versions.
If you are a using the , the simple function show below is a wrapper around venv to activate a python virtual environment if one already exists in .venv
in the current directory or create a new virtual environment and activate it if one does not already exist.
Here is the usage of venv which explains what the various flags do. From .
provides a template for creating a python project using the hatch build system with CI support using ORNL's GitLab instance, complete with development documentation, linting, commit hooks, and editor configuration.
See for details on the template.
When a specific version of python is required, can be used to create a virtual environment with the specific version of python.
See and for details.