Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Python installation

News Scripting Languages

Best Python books for system administrators

Recommended Links Python installation pdb ó The Python Debugger
Compiling Python from source Installing Python 3 from RPMs Installing Python Packages      
Debugging in Python Algorithms Quotes Python history Tips Etc

Currently Python 2.6 is installed by defult of RHEL 6.x and python 2.7 on RHEL 7.

If you need Python 3.6 you need to install it yourself. There are three ways to do it

As of November  2017, the latest Python 3.x versions available in RPMS CentOS/RHEL 7 and Debian 8/9 are 3.4 and 3.5 respectively.


Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

[Dec 05, 2017] python - Problems installing python3 on RHEL - Stack Overflow

Dec 05, 2017 | stackoverflow.com

gecco ,Nov 13, 2011 at 13:53

It is easy to install it manually:
  1. 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
  2. Unzip
    $ tar xf Python-3.* 
    $ cd Python-3.*
  3. Prepare compilation
    $ ./configure
  4. Build
    $ make
  5. 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)

rajadhiraja ,Jul 9, 2012 at 17:58

You used: bzip2 -cd Python-3.2.2.tar.bz2 | tar xvf - This is also a simpler possibility: tar jxvf Python-3.2.2.tar.bz2 – rajadhiraja Jul 9 '12 at 17:58

dannysauer ,Oct 29, 2014 at 21:38

The bzip2 option to tar was -y on some early systems, before bzip2 was "officially" supported, and some systems that don't use GNU tar don't even have bzip2 support built-in (but may have bzip2 binaries). So depending on how portable things need to be, the bunzip2 -c command (or bzip2 -cd ) may be more portable. RHEL6, as in teh question, supports -j , so this is moot for the actual question. But for posterity... – dannysauer Oct 29 '14 at 21:38

Caleb ,Jan 8, 2015 at 20:39

I got a 301 (moved) into a 404 when using the bz2 tar. I changed it to .tgz and it downloaded fine. – Caleb Jan 8 '15 at 20:39

bnu ,Jun 3, 2016 at 13:10

if you get no acceptable C compiler found in $PATH when installing python refer to http://stackoverflow.com/questions/19816275/no-acceptable-c-‌​compiler-found-in-pa‌​th-when-installing-p‌​ythonbnu Jun 3 '16 at 13:10

Searene ,Nov 20, 2016 at 3:44

./configure --with-ensurepip=install to enable pip3 , or you won't have pip3 installed after compilation. – Searene Nov 20 '16 at 3:44

Samuel Phan ,Apr 26, 2014 at 23:30

Installing from RPM is generally better, because: Solution 1: Red Hat & EPEL repositories

Red Hat has added Python 3.4 for CentOS 6 and 7 through the EPEL repository.

Unfortunately:

[EPEL] How to install Python 3.4 on CentOS 6 & 7
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

# I guess you would like to install virtualenv or virtualenvwrapper
sudo pip3 install virtualenv
sudo pip3 install virtualenvwrapper

If you want to use pyvenv , you can do the following to install pip3 in your virtualenv:

pyvenv --without-pip my_env
curl https://bootstrap.pypa.io/get-pip.py | my_env/bin/python

But if you want to have it out-of-the-box, you can add this bash function (alias) in your .bashrc :

pyvenv() { /usr/bin/pyvenv --without-pip $@; for env in $@; do curl https://bootstrap.pypa.io/get-pip.py | "$env/bin/python"; done; }
Solution 2: IUS Community repositories

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/GettingStarted/

[IUS] How to install Python 3.5 on CentOS 6
sudo yum install -y https://centos6.iuscommunity.org/ius-release.rpm
sudo yum install -y python35u python35u-pip

# I guess you would like to install virtualenv or virtualenvwrapper
sudo pip3.5 install virtualenv
sudo pip3.5 install virtualenvwrapper

Note: you have pyvenv-3.5 available out-of-the-box if you don't want to use virtualenv .

[IUS] How to install Python 3.5 on CentOS 7
sudo yum install -y https://centos7.iuscommunity.org/ius-release.rpm
sudo yum install -y python35u python35u-pip

# I guess you would like to install virtualenv or virtualenvwrapper
sudo pip3.5 install virtualenv
sudo pip3.5 install virtualenvwrapper

Note: you have pyvenv-3.5 available out-of-the-box if you don't want to use virtualenv .

Samuel Phan ,Jul 3, 2015 at 14:54

Fixed the IUS release package URL. they have updated the version, that's all. If they update the package again, you can check the link to their RPM from the webpage. – Samuel Phan Jul 3 '15 at 14:54

Samuel Phan ,Sep 7, 2015 at 9:01

As I said, the link in your answer contains non-printable unicode characters. When I copy/paste your link, here is what I see in VIM: https://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/i‌​u<200c><200b>s-relea‌​se-1.0-14.iu‌​s.cent‌​os6.noarch.rpm Here is the unicode character: fileformat.info/info/unicode/char/200c/index.htm The URL in my original answer works, I've just tested it. – Samuel Phan Sep 7 '15 at 9:01

Loïc ,Sep 30, 2015 at 13:48

Using this solution, how would you then install pip for python34 ? – Loïc Sep 30 '15 at 13:48

Samuel Phan ,Oct 1, 2015 at 21:11

Very good question, I added a comment for that. It's the best I found. If you want to stick to RPM-based installation, you should use IUS repositories for CentOS 7. They provide a python34u-pip . – Samuel Phan Oct 1 '15 at 21:11

ILMostro_7 ,May 5 at 2:27

easy_install pip3 should work--or a variation of it--to get pip3 installed without needing to curl a specific URL that may or may not be there (anymore). – ILMostro_7 May 5 at 2:27

rsc ,Jul 29, 2012 at 11:15

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

cababunga ,Feb 12, 2013 at 19:45

Why /opt ? /usr/local specifically exists for this purpose and that's where ./configure with no explicit --prefix will place it. – cababunga Feb 12 '13 at 19:45

rsc ,Feb 13, 2013 at 11:27

@cababunga As I wrote I have been influenced by reading tutorial from specified site. Nevertheless installing python in above way may be usable - it would be a lot easier to uninstall it (it looks like uninstall target for make is not provided). Also you could easily install various versions of python3 in specified separate directories under /opt and manually set which one to use or test. – rsc Feb 13 '13 at 11:27

Caleb ,Jan 8, 2015 at 21:24

You may also want to set up your PATH to contain the binaries folder. For me it was export PATH=$PATH:/opt/python3/binCaleb Jan 8 '15 at 21:24

Paul Draper ,Jan 30, 2014 at 7:52

Use 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.)

snacks ,Sep 24, 2014 at 13:23

After reading the redhat docs what I needed to do was either; scl enable python33 bash to launch a new shell which will be enabled for python 3 or scl enable python33 'python hello.py' which will run your python file using python 3 in the current shell – snacks Sep 24 '14 at 13:23

Nathan Basanese ,Aug 24, 2015 at 21:46

// , What more generic instructions would also allow the installation of Python 3.4? – Nathan Basanese Aug 24 '15 at 21:46

Florian La Roche ,Feb 3, 2013 at 8:53

You can download a source RPMs and binary RPMs for RHEL6 / CentOS6 from here

This is a backport from the newest Fedora development source rpm to RHEL6 / CentOS6

cababunga ,Feb 12, 2013 at 19:40

That's great. Thanks for your effort, Florian. Maybe running createrepo on those directories would make them even more useful for some people. – cababunga Feb 12 '13 at 19:40

lyomi ,Mar 21, 2014 at 15:18

What a relief. the rpm installed perfectly. – lyomi Mar 21 '14 at 15:18

Nathan Basanese ,Sep 3, 2015 at 20:45

// , How do we make a repository from that link? – Nathan Basanese Sep 3 '15 at 20:45

Nathan Basanese ,Sep 3, 2015 at 21:07

// , I can confirm that this works. Hold on, I just whipped up something quick that used that URL as the baseurl : 0bin.net/paste/Nathan Basanese Sep 3 '15 at 21:07

rkuska ,Jul 16, 2015 at 7:58

Python3 was recently added to EPEL7 as Python34.

There is ongoing (currently) effort to make packaging guidelines about how to package things for Python3 in EPEL7.

See https://bugzilla.redhat.com/show_bug.cgi?id=1219411
and https://lists.fedoraproject.org/pipermail/python-devel/2015-July/000721.html

Nathan Basanese ,Aug 24, 2015 at 21:57

// , What's the hold-up? Pip seems like the simple way to go. – Nathan Basanese Aug 24 '15 at 21:57

Mike Guerette ,Aug 27, 2015 at 13:33

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.

edit

Follow these instructions to install Python 3.4 on RHEL 6/7 or CentOS 6/7:
# 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

Nathan Basanese ,Dec 10, 2015 at 23:53

// , Doesn't this require us to enable a special shell? Combined with virtualenvs, I can see that becoming a pain in the ass. – Nathan Basanese Dec 10 '15 at 23:53

Nathan Basanese ,Dec 10, 2015 at 23:55

// , Why does this require scl enable rh-python34 bash ? What are the implications for using this later on? – Nathan Basanese Dec 10 '15 at 23:55

Searene ,Nov 20, 2016 at 2:53

Is there a way to install python3.5 on RedHat 6? I tried wget https://www.softwarecollections.org/en/scls/rhscl/rh-python3‌​5/epel-6-x86_64/down‌​load/rhscl-rh-python‌​35-epel-6-x86_64.noa‌​rch.rpm , but it was not found. – Searene Nov 20 '16 at 2:53

daneel ,Apr 2, 2015 at 14:12

If you want official RHEL packages you can use RHSCL (Red Hat Software Collections)

More details:

You have to have access to Red Hat Customer Portal to read full articles.

Nathan Basanese ,Aug 24, 2015 at 21:55

// , Just upvoted. Would you be willing to make a summary of what one does to use the RHSCL for this? This is a question and answer site, after all. – Nathan Basanese Aug 24 '15 at 21:55

amphibient ,Feb 8 at 17:12

yum install python34.x86_64 works if you have epel-release installed, which this answer explains how to, and I confirmed it worked on RHEL 7.3
$ cat /etc/*-release
NAME="Red Hat Enterprise Linux Server"
VERSION="7.3 (Maipo)

$ type python3
python3 is hashed (/usr/bin/python3)

Aty ,Feb 11 at 20:47

Here are the steps i followed to install Python3:

yum install wget

wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz

sudo tar xvf Python-3.*

cd Python-3.*

sudo ./configure --prefix=/opt/python3

sudo make

sudo make install

sudo ln -s /opt/python3/bin/python3 /usr/bin/python3

$ /usr/bin/python3

Python 3.6.0

Nagev ,Mar 6 at 18:21

Three steps using Python 3.5 by Software Collections :
sudo yum install centos-release-scl
sudo yum install rh-python35
scl enable rh-python35 bash

Note that sudo is not needed for the last command. Now we can see that python 3 is the default for the current shell:

python --version
Python 3.5.1

Simply skip the last command if you'd rather have Python 2 as the default for the current shell.

Maxime Martineau ,May 10 at 18:02

For RHEL on Amazon Linux, using python3 I had to do :

sudo yum install python34-devel

[Dec 05, 2017] How to Install Latest Python 3.6 Version in Linux

Dec 05, 2017 | www.tecmint.com

Although we can install the core packages and their dependencies using yum and aptitude (or apt-get ), we will explain how to perform the installation from source instead.

Why? The reason is simple: this allows us to have the latest stable release of the language ( 3.6 ) and to provide a distribution-agnostic installation method.

Prior to installing Python in CentOS 7, let's make sure our system has all the necessary development dependencies:

# yum -y groupinstall development# yum -y install zlib-devel

In Debian we will need to install gcc, make, and the zlib compression / decompression library:

# aptitude -y install gcc make zlib1g-dev

To install Python 3.6 , run the following commands:

# wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tar.xz
# tar xJf Python-3.6.3.tar.xz
# cd Python-3.6.3
# ./configure
# make
# make install

[Dec 29, 2015] How to install Python3 on CentOS - Ask Xmodulo by Dan Nanni

Xmodulo

Method Two: Install Python3 from EPEL Repository

The latest EPEL 7 repository offers python3 (python 3.4 to be exact). Thus if you are using CentOS 7 or later, you can easily install python3 by enabling EPEL repository as follows.

$ sudo yum install epel-release

Then install python 3.4 and its libraries using yum:

$ sudo yum install python34

Note that this will not install matching pip. To install pip and setuptools, you need to install them separately as follows.

$ curl -O https://bootstrap.pypa.io/get-pip.py
$ sudo /usr/bin/python3.4 get-pip.py

Method Three: Install Python3 from Software Collections (SCL)

Another way to install python3 is via enabling Software Collections (SCL) repository. The SCL repository is available for CentOS 6.5 or later, and the latest SCL offers python 3.3. Once you enable the SCL repository, go ahead and install python3 as follows.

$ sudo yum install python33

To use python3 from the SCL, you need to enable python3 on a per-command basis as follows.

$ scl enable python33 <command>

You can also invoke a bash shell with python3 enabled as the default Python interpreter:

Recommended Links

Google matched content

Softpanorama Recommended

Top articles

Sites



Etc

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Haterís Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D


Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to to buy a cup of coffee for authors of this site

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Last modified: December, 26, 2017