Difference between revisions of "Software Collections:Python"

From SME Server
Jump to navigationJump to search
(Page init)
 
(Update details to install latest Python SCL version)
 
(20 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
{{WIP box}}
 
{{WIP box}}
 +
<blockquote style="float: right;">
 +
[[File:softwarecollections.png|100px]]
 +
</blockquote>
 +
<blockquote style="float: right;">
 +
[[File:python.png|250px]]
 +
</blockquote>
  
Placeholder.  
+
'''Installing and running Python via [[Software collections]]'''
 +
 
 +
Software Collections has been introduced by Redhat as a safe way to run selective applications on Redhat based distributions in an isolated environment (separate directory), thus not effecting the base installation of the OS. This provides the possibility to e.g. test an application, install a higher version then the version installed by the base system (e.g. PHP), or temporarily use an application.
 +
 
 +
Software Collections applications can be started at boot as a system service, manually or in a specific shell.
 +
 
 +
==Python==
 +
===Installation===
 +
To be able to install an application from the Software Collections, one '''must''' install software collections first. Please see [[Software collections]] on how to install this.
 +
 
 +
The below procedure if for Python 3.6, but you can also install Python 2.7 instead or even along side. Simply replace all '36' metionings with '27'. To switch between the two versions, you need to remove the enablepythonxx.sh script from the /etc/profile.d directory as described below.
 +
 
 +
 
 +
====Required repository====
 +
After installing Software Collections, the [http://wiki.contribs.org/Scl#tab=Python3 '''scl'''] repository for Python has to be added to the yum repositories. Please see [http://wiki.contribs.org/Scl#tab=Python3 '''here'''] on how the enable the [http://wiki.contribs.org/Scl#tab=Pyton3 '''scl-python36'''] repository.
 +
 
 +
 
 +
====Install application====
 +
After installing the scl-python36 repository, Python can be installed by issuing the following command:
 +
yum install rh-python36 --enablerepo=centos-sclo-rh
 +
Once installed, the application is installed on your SME Server at '''/opt/rh/rh-python36''' as an isolated environment for the application.
 +
 
 +
====Test installed application====
 +
Once Python has been installed, you can check if it is correctly installed by issuing:
 +
scl -l
 +
which will provide you a listing of all applications that are available on your system installed via Software Collections.
 +
 
 +
A simple man page about the installed application is now available via:
 +
scl enable rh-python36 'man rh-python36'
 +
press 'q' to leave the man page
 +
 
 +
 
 +
====Usage====
 +
{{Note box|More examples to follow}}
 +
 
 +
To make use of Python version 3.6.9 in the current shell environment, one needs to enter the following command:
 +
scl enable rh-python36 bash
 +
and test with:
 +
python --version
 +
 
 +
 
 +
====Enable the python 3.6 environment at boot time====
 +
The preferred way to enable scl python36 permanently at logout or (re)boot is to add a custom script called 'enablepython36.sh' to /etc/profile.d/ directory with the following content and make it executable.
 +
 
 +
#!/bin/sh
 +
source /opt/rh/rh-python36/enable
 +
export X_SCLS="`scl enable rh-python36 'echo $X_SCLS'`"
  
 
==Other articles in this category==
 
==Other articles in this category==

Latest revision as of 13:19, 5 July 2020

Warning.png Work in Progress:
This page is a Work in Progress. The contents off this page may be in flux, please have a look at this page history the to see list of changes.


Softwarecollections.png

Python.png

Installing and running Python via Software collections

Software Collections has been introduced by Redhat as a safe way to run selective applications on Redhat based distributions in an isolated environment (separate directory), thus not effecting the base installation of the OS. This provides the possibility to e.g. test an application, install a higher version then the version installed by the base system (e.g. PHP), or temporarily use an application.

Software Collections applications can be started at boot as a system service, manually or in a specific shell.

Python

Installation

To be able to install an application from the Software Collections, one must install software collections first. Please see Software collections on how to install this.

The below procedure if for Python 3.6, but you can also install Python 2.7 instead or even along side. Simply replace all '36' metionings with '27'. To switch between the two versions, you need to remove the enablepythonxx.sh script from the /etc/profile.d directory as described below.


Required repository

After installing Software Collections, the scl repository for Python has to be added to the yum repositories. Please see here on how the enable the scl-python36 repository.


Install application

After installing the scl-python36 repository, Python can be installed by issuing the following command:

yum install rh-python36 --enablerepo=centos-sclo-rh

Once installed, the application is installed on your SME Server at /opt/rh/rh-python36 as an isolated environment for the application.

Test installed application

Once Python has been installed, you can check if it is correctly installed by issuing:

scl -l

which will provide you a listing of all applications that are available on your system installed via Software Collections.

A simple man page about the installed application is now available via:

scl enable rh-python36 'man rh-python36'

press 'q' to leave the man page


Usage

Important.png Note:
More examples to follow


To make use of Python version 3.6.9 in the current shell environment, one needs to enter the following command:

scl enable rh-python36 bash

and test with:

python --version


Enable the python 3.6 environment at boot time

The preferred way to enable scl python36 permanently at logout or (re)boot is to add a custom script called 'enablepython36.sh' to /etc/profile.d/ directory with the following content and make it executable.

#!/bin/sh
source /opt/rh/rh-python36/enable
export X_SCLS="`scl enable rh-python36 'echo $X_SCLS'`"

Other articles in this category

Mysql57, PHP Software Collections, Software Collections, Software Collections Repositories, Software Collections:MariaDB, Software Collections:MongoDB, Software Collections:MySQL, Software Collections:MySQL55, Software Collections:Nodejs, Software Collections:PHP, Software Collections:PostgreSQL, Software Collections:Python, Software Collections:Ruby on Rails