Install Python 3.10 – PPA Method First, install the prerequisite for adding custom PPAs. Second, add the deadsnakes/ppa to your APT package source list with the following command. Once the repository has been imported, run an APT update to fresh your package manager to reflect the new imported PPA.
Python 3 can be installed using the official Python 3 installer. Go to the Python Releases for Mac OS X page and download the latest stable release macOS 64-bit/32-bit installer. After the download is complete, run the installer and click through the setup steps leaving all the pre-selected installation defaults.
yum on RHEL7 is written in Python 2.7 (hence the default install) and. yum on RHEL 8 is written in Python 3.6 (which is default installed).
Installing from RPM is generally better, because:
Red Hat has added through the EPEL repository:
sudo yum install -y epel-release
sudo yum install -y python34
# Install pip3
sudo yum install -y python34-setuptools # install easy_install-3.4
sudo easy_install-3.4 pip
You can create your virtualenv using pyvenv
:
pyvenv /tmp/foo
With CentOS7, pip3.6
is provided as a package :)
sudo yum install -y epel-release
sudo yum install -y python36 python36-pip
You can create your virtualenv using pyvenv
:
python3.6 -m venv /tmp/foo
If you use the pyvenv
script, you'll get a WARNING:
$ pyvenv-3.6 /tmp/foo
WARNING: the pyenv script is deprecated in favour of `python3.6 -m venv`
The IUS Community provides some up-to-date packages for RHEL & CentOS. The guys behind are from Rackspace, so I think that they are quite trustworthy...
https://ius.io/
Check the right repo for you here:
https://ius.io/setup
sudo yum install -y https://repo.ius.io/ius-release-el6.rpm
sudo yum install -y python36u python36u-pip
You can create your virtualenv using pyvenv
:
python3.6 -m venv /tmp/foo
sudo yum install -y https://repo.ius.io/ius-release-el7.rpm
sudo yum install -y python36u python36u-pip
You can create your virtualenv using pyvenv
:
python3.6 -m venv /tmp/foo
It is easy to install python manually (i.e. build from source):
Download (there may be newer releases on Python.org):
$ wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tar.xz
Unzip
$ tar xf Python-3.*
$ cd Python-3.*
Prepare compilation
$ ./configure
Build
$ make
Install
$ make install
OR if you don't want to overwrite the python
executable (safer, at least on some distros yum
needs python
to be 2.x, such as for RHEL6) - you can install python3.*
as a concurrent instance to the system default with an altinstall
:
$ make altinstall
Now if you want an alternative installation directory, you can pass --prefix
to the configure
command.
Example: for 'installing' Python in /opt/local, just add --prefix=/opt/local
.
After the make install
step: In order to use your new Python installation, it could be, that you still have to add the [prefix]/bin to the $PATH
and [prefix]/lib to the $LD_LIBRARY_PATH
(depending of the --prefix
you passed)
In addition to gecco's answer I would change step 3 from:
./configure
to:
./configure --prefix=/opt/python3
Then after installation you could also:
# ln -s /opt/python3/bin/python3 /usr/bin/python3
It is to ensure that installation will not conflict with python installed with yum.
See explanation I have found on Internet:
http://www.hosting.com/support/linux/installing-python-3-on-centosredhat-5x-from-source
Along with Python 2.7 and 3.3, Red Hat Software Collections now includes Python 3.4 - all work on both RHEL 6 and 7.
RHSCL 2.0 docs are at https://access.redhat.com/documentation/en-US/Red_Hat_Software_Collections/
Plus lot of articles at developerblog.redhat.com.
<opinion>
Using the SCL
yum repos may be better than other yum repos because the RPMs are developed/tested by Redhat (i.e. first-party RPMs instead of third-party). </opinion>
edit
# 1. Install the Software Collections tools:
yum install scl-utils
# 2. Download a package with repository for your system.
# (See the Yum Repositories on external link. For RHEL/CentOS 6:)
wget https://www.softwarecollections.org/en/scls/rhscl/rh-python34/epel-6-x86_64/download/rhscl-rh-python34-epel-6-x86_64.noarch.rpm
# or for RHEL/CentOS 7
wget https://www.softwarecollections.org/en/scls/rhscl/rh-python34/epel-7-x86_64/download/rhscl-rh-python34-epel-7-x86_64.noarch.rpm
# 3. Install the repo package (on RHEL you will need to enable optional channel first):
yum install rhscl-rh-python34-*.noarch.rpm
# 4. Install the collection:
yum install rh-python34
# 5. Start using software collections:
scl enable rh-python34 bash
rhel
and centos
version 7 are now on python 3.6 by default i believeUse the SCL repos.
sudo sh -c 'wget -qO- http://people.redhat.com/bkabrda/scl_python33.repo >> /etc/yum.repos.d/scl.repo'
sudo yum install python33
scl enable python27
(This last command will have to be run each time you want to use python27 rather than the system default.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With