NOTE (2019-06-20): If your project relies on Python packages that CS Staff has previously installed at the system level, please migrate your project to a virtual environment immediately. We no longer install packages at the system level and, at our next major update of the Linux distribution on cycles, ionic, courselab, and armlab, we will not carry forward such packages.
The original design of Python and its packaging system puts installed packages alongside the Python interpreter1 in the file system; furthermore, only a single version of a given package can be installed with a given Python interpreter. This led to issues when different projects required different versions of packages. To address this problem, Python virtual environments were developed.
In a nutshell, Python virtual environments help decouple and isolate Python installs and associated pip packages. This allows end-users to install and manage their own set of packages that are independent of those provided by the system or used by other projects.
If you still have code written for Python 2, we recommend investing the time to port it to Python 3 as soon as feasible. See: Porting Python 2 Code to Python 3. The end-of-life (EOL) for Python 2 was January 1, 2020.
Because Python is an essential part of Linux distributions (i.e., used by the system itself), the default version and availability of Python is generally fixed until the next upgrade of the overall operating system. This means the installed Python tends to be older than current, stable versions available from python.org.
As noted above, this version is a bit dated and is missing out on goodies available in more recent versions such as Data Classes (PEP 557), Structural Pattern Matching, a handy = specifier in f-strings, and many type hinting features.
When you set up a virtual environment (details below), you can immediately use it by invoking python using the full path to the bin subdirectory within your venv (e.g., myvenv/bin/python my_program.py). For convenience, when you set up a venv, it provides an activate script that you can invoke which will put the bin subdirectory for your venv first on your PATH. (It also updates your shell prompt to let you know this change is in effect). When your venv is activated, you no longer need to use the full path to the Python interpreter (e.g., you can simply use python my_program.py).
Virtual environments let you have a stable, reproducible, and portable environment. You are in control of which packages versions are installed and when they are upgraded. You can have as many venvs as you want.
Virtual environment support is provided out-of-the-box with modern versions of Python.3 However, it is not the only mechanism one can use to maintain a reproducible environment over which you have control of the version of Python used, the packages installed, and the schedule of when they are updated. Other options available on CS systems include installing and using Conda in your home directory or project space or using Singularity.
In this section, we describe how to create a virtual environment (venv) and install a package within that venv. We are building on the example above where we have a locally built Python 3.10 interpreter in /n/fs/myproject/py310/bin.
Note: when creating a virtual environment we recommend that you specify the major and minor version number as we have done in the above examples. This will create aliases (i.e., symbolic links) in your virtual environment for python, pythonN, and pythonN.M. This will give you the flexibility of using pythonN.M in your scripts or documentation should you choose to do so.
Virtual environment directories are not suited for source control. However, a virtual environment is defined by the version of the Python interpreter and the set of packages (with specific version numbers) installed. Therefore, a common practice is to use pip freeze to create a file called (by convention) requirements.txt which contains the list of packages:
When one checks out or clones the project from a repository for the first time, they then must create a local virtual environment with the appropriate version of the Python interpreter, "activate" the environment, and use pip install with the -r option, as follows:
A significant downside to committing the output of pip freeze to source control is that it is easy to lose track of which packages are your dependencies and which packages are indirect dependencies (i.e., dependencies of your dependencies). One approach to dealing with this, is to keep your dependencies in either a requirements.in or setup.py file and use a tool such as pip-tools to manage dependencies.
It is very difficult to rename or move a virtual environment (simply renaming the directory won't work). It is better to create a new virtual environment with the same installed packages. First, extract the packages using the freeze command to the pip module:
Note that a virtual environment is tied to a particular (major, minor) version of Python. This is established via a symbolic link in the bin subdirectory of the virtual environment directory to the actual Python interpreter binary. If the target of the symbolic link no longer exists or changes to a different version of Python, the virtual environment will no longer function and must be rebuilt.
In order for a virtual environment to function on a server different from the server it was created on, it must (1) the directory must exist in the same relative position in the file system, and (2) the symbolic link in the bin subdirectory must (still) point to Python interpreter of the same version.4
For example, if you log in to cycles you will actually end up on one of the following servers: soak, wash, rinse, or spin. Because the cycles machines are kept in sync with respect to installed software and because they mount project space identically, a virtual environment that was created while you were logged in to soak will work just fine if used while you are later logged in to rinse.
For maximum flexibility and portability, you can build a local copy of a Python in your project space. A virtual environment created with such a local copy will then be available on any of the CS Systems that mount project space (including the project-space web servers).
The pip package is a binary extension module that requires ABI versions of installed shared libraries that are newer than what is installed on our systems. This can happen if the pip package is not compliant with, for example, PEP 571.5
With CentOS Linux 7 reaching end of life on June 30, 2024, organizations running CentOS Linux must migrate to a new operating system to continue receiving updates, security patches, and new features. To ease your migration from CentOS Linux to Red Hat Enterprise Linux, we've created additional resources to prepare new and existing customers for a seamless migration.
Red Hat Enterprise Linux (RHEL) 7 will reach end of maintenance support on June 30, 2024, hence it is important for our existing and new customers to plan their upgrade activities to the latest versions of RHEL. Customers have indicated the importance that upgrading is not stressful or disruptive. As a result, Red Hat has developed resources, tools, and consulting offerings needed for customers to keep their systems running.
Lab access for Red Hat training courses* that include a virtual training environment or associated lab has been extended to 45 days after the end date of the class. This change is directly related to feedback from students that old lab timeframe (not defined, typically cut off within a week) was too short to further develop skills from courses. *There are a few courses the extension doesn't apply to which are outlined in the linked blog.
All technical documentation on the Red Hat Customer Portal recently received a facelift based on customer feedback. Notable areas of improvement include improved readability, accessibility, responsiveness, and interactivity.
Customers have expressed how critical it is that Red Hat understands and prioritizes their support cases based on business impact. To better understand this, customers can now indicate business impact while creating a support case, when requesting an escalation, and when updating the severity of a case. A question has also been added to the Customer Effort Score (CES) survey that allows customers to indicate whether or not they felt that the technical engineer understood the business impact of their case once closed.
Red Hat OpenShift Container Platform customers requested an action-oriented, guided experience for new users to get started with OpenShift using the web console and the CLI. As a result, a new document was created that includes definitions for common terms found in Kubernetes and OpenShift Container Platform. The documentation also contains a walkthrough of the OpenShift Container Platform web console, as well as tips for creating and building applications by using the command-line interface.
Customers were looking for additional guidance on how to extend Prometheus metrics monitoring in KIE Server in our Red Hat Process Automation Manager (RHPAM) documentation. Given that the steps for setting it up can be slightly different in OpenShift, our Red Hat product documentation team added in additional steps to our RHPAM 7.11 documents.
The release of Red Hat Satellite 6.9 has improved the upgrade process for Red Hat Enterprise Linux (RHEL). Leapp upgrades can now be applied to the clients of the Satellite infrastructure. The Red Hat Support team identified the major pain points that customers experienced with their Leapp upgrade and provided information on how to address them in the linked blog.
With multiple Red Hat Ansible Tower versions available, customers faced issues finding and selecting the correct documentation for their version. To improve ease of navigation, a drop-down version selector menu has been added to Red Hat Ansible Tower documentation. This eliminates the need for customers to manually update the version number in their URL and makes relevant resources available with the click of a finger.
795a8134c1