On linux SUSE or RedHat, how do I load Python 2.7
Instructions to download source and install:
https://www.python.org/download/
NOTE: You should check for the latest version of python 2.7.x, as it gets updated frequently. Currently (Oct 2017), the latest version is 2.7.14 though this comment will get old and new versions likely will be released every 6 months or so.
wget https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz # Download
tar xvfz Python-2.7.14.tgz # unzip
cd Python-2.7.14 # go into directory
./configure
make # build
su # or 'sudo su' if there is no root user
make altinstall
(EDIT: make install -> make altinstall per Ignacio's comment).
Two versions of python on linux. how to make 2.7 the default
You probably don't actually want to change your default Python.
Your distro installed a standard system Python in /usr/bin
, and may have scripts that depend on this being present, and selected by #! /usr/bin/env python
. You can usually get away with running Python 2.6 scripts in 2.7, but do you want to risk it?
On top of that, monkeying with /usr/bin
can break your package manager's ability to manage packages. And changing the order of directories in your PATH
will affect a lot of other things besides Python. (In fact, it's more common to have /usr/local/bin
ahead of /usr/bin
, and it may be what you actually want—but if you have it the other way around, presumably there's a good reason for that.)
But you don't need to change your default Python to get the system to run 2.7 when you type python
.
First, you can set up a shell alias:
alias python=/usr/local/bin/python2.7
Type that at a prompt, or put it in your ~/.bashrc
if you want the change to be persistent, and now when you type python
it runs your chosen 2.7, but when some program on your system tries to run a script with /usr/bin/env python
it runs the standard 2.6.
Alternatively, just create a virtual environment out of your 2.7 (or separate venvs for different projects), and do your work inside the venv.
Where to find Python 2.7.14 RPM packages for SLES 11
What you're asking for is a Software Collection. I just checked and their Python 2.7 is still at 2.7.13 at this time, but they have instructions on how to build your own.
Do not change out the default system-level python (as suggested in some comments)! Bad things can happen and things like yum
can break.
How to install python developer package?
yum install python-devel
will work.
If yum
doesn't work then use
apt-get install python-dev
Multiple Python versions on the same machine?
I think it is totally independent. Just install them, then you have the commands e.g. /usr/bin/python2.5
and /usr/bin/python2.6
. Link /usr/bin/python
to the one you want to use as default.
All the libraries are in separate folders (named after the version) anyway.
If you want to compile the versions manually, this is from the readme file of the Python source code:
Installing multiple versions
On Unix and Mac systems if you intend to install multiple versions of Python
using the same installation prefix (--prefix argument to the configure
script) you must take care that your primary python executable is not
overwritten by the installation of a different version. All files and
directories installed using "make altinstall" contain the major and minor
version and can thus live side-by-side. "make install" also creates
${prefix}/bin/python3 which refers to ${prefix}/bin/pythonX.Y. If you intend
to install multiple versions using the same prefix you must decide which
version (if any) is your "primary" version. Install that version using
"make install". Install all other versions using "make altinstall".For example, if you want to install Python 2.5, 2.6 and 3.0 with 2.6 being
the primary version, you would execute "make install" in your 2.6 build
directory and "make altinstall" in the others.
Related Topics
How to Join Two Dataframes For Which Column Values Are Within a Certain Range
Calculate Time Difference Between Two Pandas Columns in Hours and Minutes
How to Create a User in Linux Using Python
Find Broken Symlinks with Python
A Function Callback Every Time a Key Is Pressed (Regardless of Which Window Has Focus)
What Are the Tkinter Events for Horizontal Edge Scrolling (In Linux)
Unit Testing File Modifications
Need a Way to Determine If a File Is Done Being Written To
Python Program with Notification in Gnome Shell Doesn't Work
Boolean Operators VS Bitwise Operators
How to Remove List Elements in a For Loop in Python
How to "Watch" a File for Modification/Change
Find the Oldest File (Recursively) in a Directory
How to Get the Owner and Group of a Folder with Python on a Linux MAChine
How to Check the Data Transfer on a Network Interface in Python
Error: Could Not Build Wheels for Glpk Which Use Pep 517 and Cannot Be Installed Directly