This tutorial will show you how to install the latest version of Python 2 and Python 3 on CentOS by compiling from source. The examples below are for Python 2.7.13 and Python 3.6.2, but the procedure is the same for any modern version of Python.

If you are using CentOS 6 you can use this tutorial to install both Python 2.7.x and Python 3.6.x. For CentOS 7 only the Python 3.6.x instructions below are applicable. Warning! Do not install Python 2.7.13 on CentOS 7 using these instructions. Your system will end up having two different python2.7 binaries, each with its own package directory. This will likely cause difficult-to-diagnose problems.

This tutorial should work for all versions of CentOS 6 and CentOS 7, and it will probably work on the corresponding RHEL distributions as well. I have verified it on CentOS 6.9 64 bit and CentOS 7 (1611) 64 bit.

This tutorial is meant for people that are comfortable with compiling and installing applications from source.

What is the problem?

CentOS ships with Python as a critical part of the base system. Because it is a critical part it is not getting updated, other than to plug security vulnerabilities. The lack of updates means that CentOS 6 users are stuck with Python 2.6.6 released in August 2010, and CentOS 7 users are stuck with Python 2.7.5 released in May 2013.

Solving the problem

Utilities such as yum will break if the default Python interpreter is upgraded or replaced. The trick is to install new versions of Python in /usr/local (or some other non-standard location) so that they can live side-by-side with the system version.

Things to consider

Before you compile and install Python there are a few things you should know and/or consider:

Unicode

Python has a long and complicated history when it comes to Unicode support. Unless you have very specific reasons you should configure Python 2.7 to enable UTF-32 support. This increases memory usage but improves compatibility. In Python 3.3+ the Unicode support has been completely rewritten and strings are automatically stored using the most efficient encoding possible.

You enable UTF-32 in Python 2.7 by passing --enable-unicode=ucs4 to the configure command.

Shared library

You should compile Python as a shared library. All modern Linux distros ship with Python compiled as a shared library, and there are third-party tools such as mod_wsgi and Blender that won’t work without it. To make sure the executable can find its shared library you need to pass some additional flags to the configure command (LDFLAGS="-Wl,-rpath /usr/local/lib").

Use “make altinstall” to prevent problems

It is critical that you use make altinstall when you install your custom version of Python. If you use the normal make install you will end up with two different versions of Python in the filesystem both named python. This can lead to problems that are very hard to diagnose.

Preparations – install prerequisites

In order to compile Python you must first install the development tools and a few extra libs. The extra libs are not strictly needed to compile Python but without them your new Python interpreter will be quite useless.

Execute all the commands below as root either by temporarily logging in as root or by using sudo.

Download, compile and install Python

Here are the commands to download, compile and install Python.

After running the commands above your newly installed Python interpreter will be available as /usr/local/bin/python2.7 or /usr/local/bin/python3.6. The system version of Python 2.6.6 will continue to be available as /usr/bin/python, /usr/bin/python2 and /usr/bin/python2.6.

You might also want to strip symbols from the shared library to reduce the memory footprint.

Install/upgrade pip, setuptools and wheel

Each Python interpreter on your system needs its own install of pip, setuptools and wheel. The easiest way to install or upgrade these packages is by using the get-pip.py script.

The packages will end up in /usr/local/lib/pythonX.Y/site-packages/ (where X.Y is the Python version).

What’s next?

If you are using Python 2.7 I strongly recommend that you install virtualenv and learn how to use it. Virtualenv makes it possible to create isolated Python environments. If you are using Python 3.3+ then you don’t need virtualenv because that functionality is already built in.

Each isolated Python environment (also called sandbox) can have its own Python version and packages. This is very useful when you work on multiple projects or on different versions of the same project.

Create your first isolated Python environment

Changelog

2017-07-20

  • Examples updated with Python 3.6.2.

2017-05-24

  • Examples updated with Python 3.6.1.

2017-02-08

  • Add warning about not installing Python 2.7 on CentOS 7 (since it already has 2.7 in the base system).

2017-02-07

  • Examples updated with Python 2.7.13 and Python 3.6.0.
  • Mention that this also works for installing Python 3.6 on CentOS 7.
  • Added expat-devel to the list of prerequisites.
  • Removed ldconfig instructions.
  • Added instructions for stripping the shared libraries.
  • Changed the instructions for pip/setuptools to use the get-pip.py script.

2014-03-15

  • Examples updated with Python 3.3.5.

2014-02-16

  • The Python versions used in the examples have been updated to 2.7.6 and 3.3.4.
  • The list of library prerequisites has been extended so that more features are compiled into Python.
  • New parameters for compiling Python with a shared library and for enabling Unicode UTF-32 support in Python 2.7 and Python 3.2 have been added.
  • Instructions for installing and using setuptools, pip, virtualenv and pyvenv have been added/updated.
How to install the latest version of Python on CentOS
Tagged on:     

358 thoughts on “How to install the latest version of Python on CentOS

    • 2016-05-21 at 05:47
      Permalink

      In order to compile Python you must first install the development tools and a few extra libs. The extra libs are not strictly needed to compile Python but without them your new Python interpreter will be quite useless

      sudo yum groupinstall “Development tools”

      sudo yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

      Here are the commands to download, compile and install Python

      cd /usr/local/src
      sudo wget http://python.org/ftp/python/3.2.2/Python-3.2.2.tar.xz –no-check-certificate
      sudo tar xf Python-3.2.2.tar.xz
      cd Python-3.2.2
      sudo ./configure –prefix=/usr/local –enable-shared LDFLAGS=”-Wl,-rpath /usr/local/lib”
      sudo make && sudo make altinstall

      After running the commands above your newly installed Python interpreter will be available as /usr/local/bin/python3.2

      /usr/local/bin/python3.2

      Download and install Setuptools + pip

      cd /usr/local/src
      sudo wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
      sudo /usr/local/bin/python3.2 ez_setup.py
      sudo /usr/local/bin/easy_install-3.2 pip

      Create your isolated Python 3.2 environment

      sudo /usr/local/bin/pip3.2 install virtualenv
      sudo /usr/local/bin/virtualenv /usr/local/virtenv3.2
      cd /usr/local/virtenv3.2
      source bin/activate
      python –version # (To check version)

      Reply
  • 2012-08-17 at 06:33
    Permalink

    Thanks Daniel. I second Onur.

    I have two serpents now 🙂

    Reply
  • 2012-08-29 at 04:22
    Permalink

    hello,
    after all this steps
    i got this error when i use yum
    No module named yum
    how to fix it
    thank you

    Reply
    • 2012-08-29 at 22:13
      Permalink

      Are you sure you installed your new python version using the command “make altinstall”. If you just used “make install” then you have replaced the system version (/usr/bin/python).

      I think you can fix your problem simply by copying or linking /usr/bin/python2.6 to /usr/bin/python

      Reply
      • 2014-09-29 at 02:45
        Permalink

        Ran into the same issue when trying, of all things, to update bash against the Bourne shell vulnerability. It took me about 12 hours to figure out that the system python was using the wrong libraries (for Fedora 19, the system python is at 2.7.5, and every time I ran python or did a python -V I got the wrong version).

        I ended up commenting out the reference to /usr/local/lib in ld.so.conf, and everything was good.

        Greg–

        Reply
        • 2014-10-29 at 19:38
          Permalink

          I can confirm this in Scientific Linux 6.4 as well. Took me more than 12 hours to figure out the problem though as I had installed new versions of Python and gcc. Removed /usr/local/lib from /etc/ld.so.conf, ran ldconfig, and my system is back to normal now.

          Reply
          • 2014-12-12 at 17:09
            Permalink

            Agreed. Adding python to ldconfig is a bad idea, that will normally manifest itself later on. Rather than removing /usr/local/lib, I would either put python in a different prefix (/usr/local/python for example) or replace /usr/local/lib with more explicit /usr/local/lib/ in the ldconf. After all, you’re probably going to need access to some libraries in /usr/local…

        • 2016-05-23 at 16:05
          Permalink

          Thanks for this comment. It helped me figure out why yum wasn’t working after I compiled Python 2.7.8 with /usr/local/lib in ld.so.conf on a Red Hat 7.2 system whose system-wide default is Python 2.7.5. (I had executed sudo ./configure followed by sudo make. Hadn’t got to the sudo make altinstall step).

          However, if I try the other option
          $sudo ./configure –prefix=/usr/local/python –enable-unicode=ucs4 –enable-shared LDFLAGS=”-W1,-rpath /usr/local/python/lib” I encounter the error:

          configure: error: C compiler cannot create executables
          See `config.log’ for more details

          config.log contains the error message:
          gcc: error: unrecognized command line option ‘-W1,-rpath’

          How do I work around/fix this issue?

          Reply
          • 2016-05-24 at 11:31
            Permalink

            My mistake – I had a typo in LDFLAGS. It should be -Wl and not -W1 (lower case L instead of digit 1). It worked fine with the correction.

      • 2017-07-03 at 02:54
        Permalink

        To me send me error in Python, how to replace from python27 to python?

        Reply
  • 2012-09-26 at 03:14
    Permalink

    how do add something to the pythonpath of python2.7

    Reply
  • 2012-09-29 at 02:07
    Permalink

    beautiful. worked perfect. Thanks for publishing. got me out of zlib error hell for a parallel python 2.7 install.

    Reply
  • Pingback: Backing up to Amazon Glacier | Jacob Allred

  • 2012-10-17 at 15:54
    Permalink

    How to fix no module name _sqlite3 ?

    Reply
    • 2012-10-17 at 19:45
      Permalink

      You need to have the sqlite-devel package installed before you configure and make python. Install it with “yum install sqlite-devel”.

      Reply
  • 2012-10-27 at 17:25
    Permalink

    Very nice, but how about throwing in a # yum install readline-devel? Makes the python interpreter easier to work with later (not to mention ipython).

    Reply
    • 2013-01-17 at 15:19
      Permalink

      Thanks Erik, after installing readline-devel, config detects the readline libs automatically, and compile in the support by default… the command line is way better!

      Reply
  • 2012-10-31 at 00:59
    Permalink

    I see failure when installing Tkinter using “easy_install-2.7 Tkinter”. How can I make it work?

    error: Could not find suitable distribution for Requirement.parse(‘Tkinter’)

    I needed another module ‘pexpect’ and “easy_install-2.7 pexpect” worked fine.

    Reply
    • 2012-10-31 at 04:12
      Permalink

      Issue fixed: After ‘yum install tk-devel’ and then reinstall python “make && make altinstall” I was able to import Tkinter properly. Didnt have to install Tkinter explicitly using “easy_install-2.7 Tkinter”

      Reply
      • 2012-11-29 at 01:47
        Permalink

        Thank you for the information! I will include this in the updated guide that I will post shortly.

        Reply
      • 2014-03-24 at 19:01
        Permalink

        Thanks Sanjay! That fixed a persistent problem that I had. I’m so glad you took the trouble to post. I had tkinter working in the (default) Python2.6, so I knew that all the necessary .so files were installed, but I forgot/didn’t realize that the tk-devel files would be necessary during the compilation of Python2.7.

        Reply
  • 2012-10-31 at 18:23
    Permalink

    after following all above steps, it istalled python 2.7(i checked directory where it install, its ok) but when i check python -V. it show python 2.6.6 instead of python 2.7. please help me how to change default python 2.6 to 2.7.

    Reply
    • 2012-11-29 at 01:45
      Permalink

      You do NOT want to change default python version because that breaks some system services (like yum for example). You have two options:

      1. Always use “python2.7” instead of “python” when you start python scripts.
      2. Set up a virtualenv with python 2.7 and run everything from inside that virtualenv.

      Reply
      • 2013-12-14 at 03:13
        Permalink

        i got this error “-bash: python2.7: command not found” after typing python2.7 setup.py install on your instruction in Download and install Distribute for Python 2.7, how can i overcome this wall? thanks in advance

        Reply
  • 2012-11-06 at 16:31
    Permalink

    This is fantastic. Thank you!

    Reply
  • 2012-11-06 at 16:50
    Permalink

    Thank you for doing this! I am having one problem…When I run:
    python2.7 setup.py install

    I get:
    bash: python2.7: command not found

    Reply
    • 2012-11-29 at 01:41
      Permalink

      Do you have an executable named /usr/local/bin/python2.7? Is /usr/local/bin on your PATH?

      Reply
  • 2012-11-16 at 23:11
    Permalink

    Works great! Thanks a lot 🙂

    Reply
  • 2012-11-26 at 05:37
    Permalink

    Very great! Works.
    Thank you.

    Reply
  • Pingback: Broken python installation on CentOS 5.8 | UmeedainTimes.com

  • 2012-11-28 at 17:09
    Permalink

    I get this error after I attempt to run Python for the first time:

    /usr/local/python2.7/bin/python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

    Reply
    • 2012-11-29 at 01:39
      Permalink

      What options did you pass to configure? It doesn’t look like you used my suggestions.

      Reply
    • 2014-11-24 at 18:29
      Permalink

      If you typed

      include ld.so.conf.d/*.conf
      /usr/local/lib

      when you installed, you may be getting this error because you forgot to run

      /sbin/ldconfig

      Just running that command fixed it for me

      Reply
  • Pingback: Хостинг WSGI з nic.ua | Roman Yepishev

  • 2012-12-18 at 16:13
    Permalink

    You made this process so easy, thanks for the detailed steps! CentOS is too “stable” to be upgraded…. Only got python24 on my server.

    Reply
  • 2012-12-19 at 13:47
    Permalink

    Thanks for the tutorial. How come there aren’t any easily obtainable RPMs for this kind of thing? It’s baffling to me that EPEL has PyPy 1.9 but no CPython 2.7.

    Reply
  • 2012-12-20 at 20:37
    Permalink

    hey thanks for the tutorial. How do we point django’s default python to this python ?

    Reply
    • 2012-12-21 at 01:49
      Permalink

      The best way is to run your Django app from inside a virtualenv. Look at the last steps in the article above for info on how to properly install virtualenv.

      Reply
  • 2012-12-21 at 21:09
    Permalink

    Thanks very much. It all worked until I saw this:
    ————————————————————————————–
    Python build finished, but the necessary bits to build these modules were not found:
    bsddb185 dl gdbm
    imageop sunaudiodev
    To find the necessary bits, look in setup.py in detect_modules() for the module’s name.

    running build_scripts
    creating build/scripts-2.7
    copying and adjusting /disk2/software/Python-2.7.3/Tools/scripts/pydoc -> build/scripts-2.7
    copying and adjusting /disk2/software/Python-2.7.3/Tools/scripts/idle -> build/scripts-2.7
    copying and adjusting /disk2/software/Python-2.7.3/Tools/scripts/2to3 -> build/scripts-2.7
    copying and adjusting /disk2/software/Python-2.7.3/Lib/smtpd.py -> build/scripts-2.7
    changing mode of build/scripts-2.7/pydoc from 644 to 755
    changing mode of build/scripts-2.7/idle from 644 to 755
    changing mode of build/scripts-2.7/2to3 from 644 to 755
    changing mode of build/scripts-2.7/smtpd.py from 644 to 755
    /usr/bin/install -c -m 644 ./Tools/gdb/libpython.py python-gdb.py
    make: stat: Modules/config.c.in: Permission denied
    make: *** No rule to make target Modules/config.c.in', needed by Makefile’. Stop.
    —————————————————————————————
    There is nothing at all in my /usr/local/bin.

    Any suggestions?

    Reply
    • 2012-12-22 at 02:49
      Permalink

      I’m far from an expert, but the Python readme contains this:
      Unix platforms: If your vendor still ships (and you still use) Berkeley DB
      1.85 you will need to edit Modules/Setup to build the bsddb185
      module and add a line to sitecustomize.py which makes it the
      default. In Modules/Setup a line like

      bsddb185 bsddbmodule.c

      should work. (You may need to add -I, -L or -l flags to direct the
      compiler and linker to your include files and libraries.)

      XXX I think this next bit is out of date:

      64-bit platforms: The modules audioop, and imageop don’t work.
      The setup.py script disables them on 64-bit installations.
      Don’t try to enable them in the Modules/Setup file. They
      contain code that is quite wordsize sensitive. (If you have a
      fix, let us know!)

      That all suggests to me that you can edit the configuration, but there may be more information lower down in the readme. For example, I had to dig to find –enable-shared, which I needed.

      Reply
      • 2012-12-23 at 03:14
        Permalink

        Thanks for replying. I think I’ve got it now. It turned out to be a file protection problem. I’ve been trying to install using “sudo make && make altinstall” but apparently sudo doesn’t let me cd to directories that I don’t have rights too. So at first I started changing all the directories I needed in the source tree to 755. I still ran into a problem installing files into /usr/local/bin – I didn’t want to change the protection there. Fortunately, I could just do “sudo su” and do the install as root.

        Reply
        • 2013-02-05 at 23:06
          Permalink

          Thanks, Dave. That did the trick for me. And thank you, Daniel, for such a useful guide.

          Reply
        • 2014-03-18 at 17:03
          Permalink

          You want to do sudo make && sudo make altinstall — need to sudo on both commands.

          Reply
          • 2014-08-05 at 22:03
            Permalink

            Something that can be easy forgotten due to the first ‘sudo’ and ‘&&’.

          • 2014-09-25 at 07:04
            Permalink

            Thank you!!! I was not adding the second sudo

        • 2014-12-24 at 01:58
          Permalink

          First I want to thank Daniel Eriksson and all others who have posted their experience and solutions. I don’t have any knowledge about building packages at this level on *nix…

          I’ve simply been following instructions listed on this page to install python-2.7.9, things went so well I’ll try 3.4.2 also…

          I encountered similar error to Dave.

          I too was using ” sudo ” to run commands to perform installs.

          After reading Dave’s post above I went back and ran everything as ” root ” ( su root ),

          ./configure –prefix=/usr/local –enable-unicode=ucs4 –enable-shared

          make && make altinstall

          ls -l /usr/local/bin/py*

          -rwxr-xr-x 1 root root 84 Dec 23 17:16 /usr/local/bin/pydoc*
          -rwxr-xr-x 1 root root 9760 Dec 23 17:47 /usr/local/bin/python2.7*
          -rwxr-xr-x 1 root root 1687 Dec 23 17:47 /usr/local/bin/python2.7-config*

          Thanks Dave, for posting complete message which I searched for and found. My issue appears to be resolved after running as ” root ” and not ” sudo ”

          Python build finished, but the necessary bits to build these modules were not found:
          bsddb185 dl imageop
          sunaudiodev
          To find the necessary bits, look in setup.py in detect_modules() for the module’s name.

          running build_scripts
          creating build/scripts-2.7
          copying and adjusting /home/sgadmn/Downloads/Python-2.7.9/Tools/scripts/pydoc -> build/scripts-2.7
          copying and adjusting /home/sgadmn/Downloads/Python-2.7.9/Tools/scripts/idle -> build/scripts-2.7
          copying and adjusting /home/sgadmn/Downloads/Python-2.7.9/Tools/scripts/2to3 -> build/scripts-2.7
          copying and adjusting /home/sgadmn/Downloads/Python-2.7.9/Lib/smtpd.py -> build/scripts-2.7
          changing mode of build/scripts-2.7/pydoc from 644 to 755
          changing mode of build/scripts-2.7/idle from 644 to 755
          changing mode of build/scripts-2.7/2to3 from 644 to 755
          changing mode of build/scripts-2.7/smtpd.py from 644 to 755
          /usr/bin/install -c -m 644 ./Tools/gdb/libpython.py python-gdb.py
          /usr/bin/install -c python /usr/local/bin/python2.7
          /usr/bin/install: cannot create regular file `/usr/local/bin/python2.7′: Permission denied
          make: *** [altbininstall] Error 1

          Reply
  • Pingback: Run in a CentOS server

  • 2013-01-18 at 09:16
    Permalink

    I managed to install python 2.7.3 without breaking yum.

    How to make a specific user to use python 2.7.3 as virtual env ?

    Reply
    • 2013-02-21 at 00:25
      Permalink

      Each virtualenv has its own Python version that is set when the virtualenv is first created. It is up to the user to decide what Python version he/she wants in each virtualenv.

      Reply
  • 2013-01-23 at 14:47
    Permalink

    Smooth as silk, thanks very much for taking the time to put this together

    Reply
  • Pingback: Installing Python 2.7 on CentOS 5 | My Blog

  • 2013-01-29 at 20:55
    Permalink

    Thanks a bunch. Was having a hard time getting python to install with many other resource I found on google. 10*

    Reply
  • 2013-02-05 at 16:56
    Permalink

    Thanks for the tutorial. I did everything you said, so if I understand correctly, now I have to install
    1) python 2.7 once again
    2) Will this virtualenv become default or how do I control it ?

    I dont know much about python and vertualenv, hence the silly questions.

    Reply
    • 2013-02-06 at 00:50
      Permalink

      If you followed the tutorial you already have everything you need. When you create a new virtualenv you will automatically get a copy of the proper version of python inside that folder structure.

      A virtualenv is never “default”, you have to manually activate it. Once activated your default python interpreter will change from the system default to the one in that particular virtualenv.

      You can have as many virtualenv as you like on a machine, and each virtualenv can have a different default python interpreter, and different installed packages.

      This is really useful when you develop multiple applications, each with different requirements. I do Django development myself and it is really useful to have one virtualenv for each project because one website might run Django 1.4, another might run 1.2 and yet another one might run 1.5 beta. I do most of my development in Eclipse with the pydev plugin, and that plugin knows about virtualenv so I just configure one interpreter for each project and point it at the python executable inside that particular virtualenv.

      Reply
    • 2013-02-06 at 01:05
      Permalink

      Maybe I should clarify that activating a virtualenv only affects your current session/shell.

      Reply
      • 2013-05-07 at 09:25
        Permalink

        I Want to run twissted protocol inside python 2.7 as it is working with python 2.6.6 . Please suggest

        Reply
  • 2013-02-11 at 10:44
    Permalink

    thanks a lot 🙂 it works! 🙂

    Reply
  • 2013-02-11 at 22:31
    Permalink

    Thank you. Worked perfect.

    Regards
    Santosh

    Reply
  • 2013-02-12 at 16:33
    Permalink

    Thanks buddy , easiest but best routine. I’m going to check your other posts.

    Reply
  • 2013-02-20 at 20:19
    Permalink

    Very useful post, you can update some version numbers that also worked for me: Centos 6.3 and distribute 0.6.35

    Reply
  • 2013-02-21 at 04:03
    Permalink

    I have now updated the tutorial with additional information provided here in the comments, plus updated versions, plus more information about virtualenv. Enjoy!

    Reply
  • 2013-02-26 at 18:54
    Permalink

    i have intsall python using altinstall command, but still it show version 2.4
    how to resolve it

    Reply
    • 2013-02-26 at 19:36
      Permalink

      The system default Python interpreter does not change, that is the whole point of this tutorial. To start your new Python interpreter you must issue the command /usr/local/bin/python2.7 (or simply python2.7 if /usr/local/bin is in your PATH which it usually is).

      Reply
  • 2013-02-27 at 07:44
    Permalink

    Hi there!
    I have problem while running “make && make altinstall”. It overlap and non-stop, i mean the installation never finished. It showing:

    By default, distutils will build C++ extension modules with “g++”.
    If this is not intended, then set CXX on the configure command line.

    And then restart the installation process.

    Reply
    • 2013-02-27 at 23:02
      Permalink

      Unfortunately I don’t know what could be causing that problem. Maybe you have installed something that messes around with your C/C++ toolchain. My only advice is to google the error message and see how others have solved it.

      Reply
  • 2013-03-04 at 05:24
    Permalink

    Dear Colleagues,

    I tried to install Python 2.7.3 and Python 3.3.0 following the method published in this blog.
    My yum is now broken and after I requested the centos forum, I was advised to uninstall these 2 versions of python. How do I uninstall them, is there a command to do this?

    With best regards,
    Philip

    Reply
    • 2013-03-04 at 17:00
      Permalink

      Are you sure you followed the instructions? Especially the part where you use ALTINSTALL instead of INSTALL? I doubt you did, because if you used ALTINSTALL then the system version of Python would still be 2.6.6.

      What is the output of the following commands:
      # python –version
      # /usr/bin/python –version

      The Python makefile does not provide an uninstall target so you will have to remove the files manually if you want that.

      Reply
      • 2013-07-05 at 21:04
        Permalink

        I did the same thing.. I thought I needed 2.7.3 along with 3.3 so I installed both.. I did do it with altinstall though.. so my yum works fine…

        How do I uninstall 3.3? I see you wrote just remove the files.. but can you be more specific as there are a ton of files?

        Reply
  • 2013-03-05 at 06:38
    Permalink

    Dear Daniel,

    Thank you for replying back. Please find the required information below.

    $ python -V
    Python 2.7

    $ yum
    -bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory

    Can we change the defauly version of python to the original 2.6.6?

    With best regards,
    Philip

    Reply
    • 2013-03-05 at 10:16
      Permalink

      Please check the version of /usr/bin/python.

      If it is 2.6.6 then your PATH is most likely in the wrong order (/usr/bin should be before /usr/local/bin).

      If it is 2.7.3 then you didn’t follow the steps in this guide. You can still salvage the situation by doing this:

      rm /usr/bin/python
      ln -s /usr/bin/python2.6 /usr/bin/python

      Reply
  • 2013-03-11 at 12:11
    Permalink

    Dear Daniel,

    You are right, I may have done a lot of more than what the guide says (I have a 64 bit system). Please kindly help me resolve this error, as most of my work is pending because I am not able to use yum. We could connect via webex/ teamviewer, please let me know when you are free and I will send you my teamviewer login details.
    I have tried out your suggestions, but the error with yum remains. Please find the below log-

    ==============================
    $rm /usr/bin/python
    rm: remove symbolic link `/usr/bin/python’? y
    $ln -s /usr/bin/python2.6 /usr/bin/python
    $yum
    -bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory
    $python -V
    Python 2.7
    ===============================

    Thanking you and with best regards,
    Philip

    Reply
    • 2013-03-11 at 22:03
      Permalink

      Verify that /usr/bin/python2.6 really is version 2.6. If it is then you have another binary called python somewhere else in your filesystem, in a location that is searched before /usr/bin. Check the order of your PATH variable.

      Reply
  • 2013-03-12 at 03:36
    Permalink

    Thanks Daniel for the great tutorial. I’ve installed PyCrypto, and it fails with the following:

    Running pycrypto-2.6/setup.py -q bdist_egg –dist-dir /tmp/easy_install-wQetbc/pycrypto-2.6/egg-dist-tmp-FPHtu0
    warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
    zip_safe flag not set; analyzing archive contents…

    Then, I ran yum install mpir, and I got:
    Package mpir-1.3.1-4.el6.x86_64 already installed and latest version .
    Similarly, it said gmp was installed and latest.

    I’ve been told I need python2.7.3-devel to get PyCrypto to build. I can get it from an RPM I found but I don’t think it’s a great idea (I have to symlink all kinds of things everywhere and then install the RPM — maybe not great.)

    Any idea how I can solve this? Also, if I want to remove Python 2.7.3: Any specific instructions?

    Thanks again!

    Reply
    • 2013-03-12 at 07:58
      Permalink

      Not sure I can help you with PyCrypto, at least not right now, but I can tell you that you already have what is included in the devel package (libs and headers).

      Removing Python is pretty easy, all the files you need to delete are located under /usr/local and fairly easy to spot. This should get you going:

      /usr/local/bin/python2.7
      /usr/local/include/python2.7 (dir)
      /usr/local/lib/libpython2.7.a
      /usr/local/lib/python2.7 (dir)

      There are a few more executables under /usr/local/bin that you can remove also (pydoc, idle, 2to3, …). List the dir in chronological order to see what other (if any) files were installed there at the same time as python2.7.

      Reply
  • 2013-03-14 at 00:28
    Permalink

    Worked on centos 5.8; I was upgrading python to 2.7.3…thanks!!

    Reply
  • 2013-03-19 at 14:27
    Permalink

    very useful article, great work, thanks!

    Reply
  • 2013-03-30 at 00:47
    Permalink

    Thanks! Worked perfectly on CentOS 6.4. I have 2.6.6, 2.7.3 and 3.3 all living in peaceful harmony.

    Reply
  • Pingback: Living Cosmos

  • 2013-04-03 at 00:45
    Permalink

    Hi Daniel,

    This is by far the best tutorial I have found for installing python 3.3 on Centos. After running into some permission errors, I successfully ran the make && make altinstall. The folder created is /usr/local/bin/python3.3m as opposed to /usr/local/bin/python3.3.

    When I try to run the command python3.3 setup.py install, I receive the error: “-bash: python3.3: command not found”. Any ideas on how to fix this?

    Reply
  • Pingback: CentOS6にpython2.7を入れる | ちいさな創々

  • 2013-04-07 at 17:04
    Permalink

    Daniel, thanks for the tutorial. This worked like a charm on Cent OS 5.7, which ships with Python 2.4.

    FYI, the newest versions are 2.7.4 and 3.3.1, released yesterday and today, respectively. I installed 2.7.4 no problem by just replacing the release version number in your instructions. (Didn’t try 3.3.1.)

    It’s great to have these straight-forward instructions for those of us who know enough about linux to easily understand & follow your tutorial, but don’t perform these actions regularly enough for them to be intuitive. (I would never have thought to install the development tools first, for example.) Thank you very much.

    Reply
  • 2013-04-15 at 17:08
    Permalink

    Worked like a charm .. Thanx Daniel

    Reply
  • Pingback: linux tips linux命令锦集

  • 2013-04-21 at 10:09
    Permalink

    Echoing everyone else – thanks for the quickie.

    Reply
  • 2013-04-23 at 01:22
    Permalink

    Sweet !!!…This worked like a charm, not even a single hiccup.

    Reply
  • 2013-04-23 at 09:50
    Permalink

    Hi Daniel,
    I am new to Linux, I am following your steps to install python3.3 on cent0s 6, all the steps works until when I get to “make && make altinstall”.
    Ithrows the following error: make: *** No targets specified and no makefile found. Stop.
    it seems that, I am not getting something right. Could you please help. Many thanks

    Reply
      • 2013-04-26 at 20:26
        Permalink

        I haven’t done 3.3, but this sound like you’re running the command in the wrong directory. Are you in the directory containing the makefile (probably actually named Makefile) ?

        Reply
        • 2013-04-28 at 00:41
          Permalink

          Thanks for the reply Dave, yes I was in the Makefile directory. All the steps from Daniel worked until when I go to “make && make altinstall” Cheers.

          Reply
          • 2013-04-28 at 01:19
            Permalink

            Most strange. Does “make –file=Makefile” behave any better ? Or “make –file=./Makefile” ? If not, I’d suggest showing us the output of “pwd; ls -l; alias make ; env |grep -i make” (all just grasping at straws.)

  • 2013-04-24 at 18:36
    Permalink

    Did anyone answer the question about setting the PYTHONPATH in the virtual environment or is that not necessary?

    Reply
  • 2013-04-26 at 17:50
    Permalink

    Just a philosophical question: what’s the point of the centos package management, if you have to install packages manually?

    Reply
    • 2013-04-27 at 23:17
      Permalink

      In this case, it’s because the CentOS repositories do not have Python 2.7 and 3 in them and the versions that they do contain are rather obsolete.

      Reply
  • 2013-05-03 at 18:00
    Permalink

    Hello,

    I’ve just updated to python3-3.3.1 as rpm packages on:
    http://jur-linux.org/download/el-updates/6/

    This is based on the newest Fedora rpm to compile on RHEL6, any additional
    testing more than welcome for people who don’t want to recompile themselves.

    best regards,

    Florian La Roche

    Reply
  • 2013-05-05 at 08:34
    Permalink

    hello, i’m trying to install anki 2.0.3 on my cent 6.x box, followed instructions, but anki rpm still says that it needs 2.7 to install? halp?

    Reply
  • 2013-05-06 at 11:39
    Permalink

    Following the instructions to build 2.7.4 on CentOS 6.4 I get

    ‘WARNING: old charecter set or encoding…’ message and a garbaged screen only starting /usr/local/bin/python2.7 but not Python

    Reply
  • Pingback: How to install Python 2.7 – On Windows, Ubuntu and CentOS | Buzz Atom - Your Way Into The Core of Nimbuzz

  • 2013-05-09 at 01:37
    Permalink

    Thanks a lott, really helpful
    Fix: I think you’re missing a j in
    tar xf Python-2.7.3.tar.bz2
    should be
    tar jxf Python-2.7.3.tar.bz2

    Reply
  • 2013-05-12 at 04:41
    Permalink

    You are so awesome. THANKS!!!!!!!!!!!!!!!

    Reply
  • 2013-05-13 at 00:01
    Permalink

    Worked perfectly with 2.7.4 and 3.3.1 on Fedora 18. I prefer to have my installations more self-contained, so I added the –prefix and –exec-prefix options to the configure command line.

    Reply
  • 2013-05-15 at 05:29
    Permalink

    Thank you so much. This is very helpful!

    Reply
  • Pingback: Not RSS 2 Email — Half-Elf on Tech

  • 2013-05-23 at 11:18
    Permalink

    Thank you all very much guys! (Dave T and Daniel). I installed GCC and after that, the “make && make altinstall” ran perfectly. Python is now upgraded to 3.3. I have been away, hence the late response, pardon. Much appreciations for your expert advice.

    Reply
  • Pingback: How to install Python 2.7 and 3.3 on CentOS 6 |...

  • 2013-05-29 at 08:19
    Permalink

    Very good instructions. It got me half of the way there, but… Do you happen to know how to get the rest of the package (2.7)? The whole point of installing 2.7 in my case was one function: to run a Cython conversion, which requires the -devel package/headers. The CentOS (version 2.6) -devel files were installed with 2.6 but could never be found found by Cython, and apparently the 2.7 from python.org. does not include -devel files at all?? I have been all over python.org’s site, but if the -devel package is there, I cannot find it. Is it available anywhere else? Obviously CentOS won’t have it, since they did not have version 2.7.

    Reply
  • 2013-06-02 at 19:18
    Permalink

    Maybe it is in the python-kitchen package, available from the Epel repo

    Reply
  • 2013-06-05 at 17:50
    Permalink

    This was clear, concise, and accurate. Thank you for taking the time to put this together– I greatly appreciate it! This saved me hours putting together the steps on my own.

    Reply
  • Pingback: Instalar Python 2.7 en CentOS 6 con mod_wsgi de forma segura | Hello, IT.

  • Pingback: Comment on How to install Python 2.7 and 3.3 on...

  • 2013-06-06 at 20:33
    Permalink

    The above instructions worked great. I am tyring to install mininet from rpm and it is complaining that it requires /usr/bin/python2.7. /usr/bin/python is 2.6.6 and /usr/bin/python2.7 is 2.7.5. Any thoughts on how to get around this dependency on /usr/bin/python being version 2.6?

    Reply
  • 2013-06-17 at 20:03
    Permalink

    This worked fantastically on CentOS 6.XX. Thank you very much!

    Reply
  • 2013-06-18 at 16:09
    Permalink

    Hello, thanks for the post, worked fine.

    In you guide you recommend to install “Distribute” but now on their website it’s written that it’s a deprecated fork of “Setuptools”. Maybe a small upgrade to your guide?

    Thanks

    Reply
  • 2013-06-18 at 19:14
    Permalink

    Worked perfectly first time on CentOS 6.4 (though I used the updated versions of each).
    Much appreciated!

    Reply
  • Pingback: Installing and compiling Python 2.7 on Centos 6.3 | Information Assurance

  • 2013-07-09 at 01:29
    Permalink

    Great post! I also added the following dependencies: gdbm-devel and db4-devel
    This allows for gdbm, dbm, and _bsddb to build.
    My final unsupported modules (after running make) for python 2.7 on x64 were:
    bsddb185 dl imageop sunaudiodev
    All of which are obsolete.
    I also second the previous poster about installing setuptools over distribute.

    Reply
  • Pingback: By: Walt | Centos 6 RHEL Linux | Scoop.it

  • 2013-07-12 at 16:34
    Permalink

    Thanks for this guide. However, I do not have root privileges on this computer. I wanted to install python 2.7 since all the codes I have written are optimized for 2.7. I also want this to be the default version and wanted to know if this was possible?

    Reply
  • 2013-07-13 at 18:18
    Permalink

    Daniel, your procedure is awesome! Thanks. I successfully installed Python 2.7.5 and distribute 0.7.3 on CentOS 6.4. I ran into an issue using wget to download distribute 0.7.3 (seems to be a certificate error), so I downloaded it directly from https://pypi.python.org/pypi/distribute/0.7.3 using http.

    Reply
  • 2013-07-16 at 22:46
    Permalink

    Daniel, Thanks for putting this up! However I’m getting:
    /usr/bin/install: cannot create regular file `/usr/local/bin/python2.7′: Permission denied
    When running “make && make altinstall” even if I run sudo with the command. I’d appreciate any help you could give!

    Reply
    • 2013-08-03 at 04:13
      Permalink

      This sounds like the issue Dave M reported on 2012/12/22, above.

      If /usr/local/bin is mounted from a remote machine, that could cause problems, too; remote root write access is often disabled on exported filesystems. Does /usr/local/bin/python2.7 already exist ? If so, who owns it, and what are the permissions ? If not, then same questions for /usr/local/bin, then /usr/local.

      As ever, I’m just grasping at straws.

      Reply
      • 2013-08-03 at 06:09
        Permalink

        I appreciate it Dave! I actually figured it out, but forgot to post back here. For whatever reason running “sudo make && make altinstall” with my sudo user didn’t work. Even if I changed the owner of the bin/python2.7 Yet then I tried running “sudo bash” then “make && make altinstall” and it work perfectly!

        Reply
        • 2013-10-17 at 23:24
          Permalink

          You should have instead done this:
          make && sudo make altinstall
          The way you did it, sudo only applies to the first make – which doesn’t even need to be done by root. Only “make altinstall” needs to run as root, because that is when files are created in /usr directories.

          Reply
      • 2013-12-08 at 05:42
        Permalink

        Worked for me using “sudo make altinstall”. If that doesnt work try “chmod 744 /usr/local/bin” (depending on your security situation). Note that if you use sudo then python2.7 will only be available to the root user.

        Reply
  • Pingback: CentOS 6.4 PYPI本地源制作 » 陈沙克日志

  • Pingback: Instalar Python | Blog de Mario Javier

  • 2013-08-22 at 03:04
    Permalink

    Hello,

    Thanks a lot by the tutorial…

    I need to install python-devel now for version 2.7.

    I tried “easy_install-2.7 python-devel” and got the following:

    Reading http://pypi.python.org/simple/python-devel/
    Couldn’t find index page for ‘python-devel’ (maybe misspelled?)
    Scanning index of all packages (this may take a while)
    Reading http://pypi.python.org/simple/
    No local packages or download links found for python-devel
    error: Could not find suitable distribution for Requirement.parse(‘python-devel’)

    Any ideas?

    Regards,

    Camps

    Reply
  • 2013-08-22 at 14:58
    Permalink

    Hi,

    I did exactly as you mentioned but how do I install python abi for 2.7 can you let me know. One of the packages I am trying to install depends on python abi 2.7 !!

    Reply
  • 2013-09-03 at 17:24
    Permalink

    Hi friends!

    # virtualenv-2.7 –distribute someproject

    Could anybody tell me one example of ‘someproject’ ?

    The domain folder root? Is this correct?

    # virtualenv-2.7 –distribute /var/www/vhosts/mydomain.es

    Thanks

    Reply
    • 2013-10-25 at 16:36
      Permalink

      “someproject” is the aliase you choose for your python. for example, you could use py273 for Python2.7.3 and the system will create a directory py273 under the ../distribute-0.7.3

      Reply
  • Pingback: Python 2.7 on Centos

  • 2013-09-27 at 06:18
    Permalink

    Hello,

    I have installed Python 2.7 by on centos 5 from source code. Python 2.4 is already there in centos 5. Could you please help me to uninstall Python 2.7 so that I can reinstall it with yum.

    Reply
  • Pingback: Sudoer statement syntax to source virtualenv activate file | BlogoSfera

  • 2013-10-02 at 03:06
    Permalink

    Any advice on installing scipy/numpy/matplotlib this way? I’m using centos 6 and was able to get python2.7 and distribute installed using the great instructions above. But “easy_install2.7 scipy” fails (even after numpy is installed).

    Reply
    • 2014-02-04 at 14:42
      Permalink

      Hi python27,
      I have the same issues as your. Did you manage to get rid of it ?
      Thanks
      rhu

      Reply
      • 2015-01-09 at 18:10
        Permalink

        My too. How do I install Numpy for Python 2.7 being installed as altinstall?

        Reply
  • 2013-10-04 at 21:21
    Permalink

    This is one of the clearest how-to articles I have encountered in years! You completely covered the steps required from A-Z. I didn’t know how much was missing from other articles until I read this. Thank you so much.

    Reply
  • 2013-10-11 at 21:37
    Permalink

    Hi I followed the steps to install python2.7 but still I run into following errors:
    http://pastebin.com/gAPLRLc2

    I guess it might be because ssl is not getting configured for my python2.7 install, am not able to get past it
    Can somebody plz help.

    Reply
  • Pingback: CentOS | Pearltrees

  • 2013-10-16 at 08:06
    Permalink

    Hi, thanks for these great and clear instructions! I only had one problem when I got to the portion of installing Distribute. The setup for Distribute would not work unless I added the option “-with-zlib=/usr/include” to the configure script line. So, like this:

    ./configure –prefix=/usr/local -with-zlib=/usr/include

    if it helps, I was on Centos 6.4, trying to install Python 2.7.5 and distribute 0.6.49.

    Reply
  • 2013-10-25 at 16:38
    Permalink

    “someproject” is the aliase you choose for your python. for example, you could use py273 for Python2.7.3 and the system will create a directory py273 under the ../distribute-0.7.3

    Reply
  • 2013-10-28 at 21:00
    Permalink

    Very awesome work Daniel. The extra tips on installing distribute and virtualenv were well worth coming here, thanks a lot.

    Also, I don’t know if anyone else pointed it out, but it is unfortunate that CentOS 6 repos don’t have a python2.7 rpm on them. I will see if they have a bug about this already, and file one if they don’t.

    Reply
  • 2013-10-29 at 10:31
    Permalink

    Works nice !

    I installed it in /usr/local/python-2.7/

    Reply
  • 2013-10-30 at 01:27
    Permalink

    When build your python, be sure to put
    “–enable-uncode=ucs4”

    Otherwise it will be built in UCS2 model, leading “undefined symbol: PyUnicodeUCS2_GetSize” errors in package matplotlib. Thanks.

    Reply
    • 2013-10-30 at 01:33
      Permalink

      Sorry, “–enable-uncode=ucs4″ should be “–enable-unicode=ucs4″, a typo.

      Reply
  • 2013-11-04 at 15:08
    Permalink

    Help im getting
    ERROR: certificate common name “*.a.ssl.fastly.net” doesn’t match requested host name “pypi.python.org”.

    Reply
    • 2013-11-08 at 19:57
      Permalink

      Add
      –no-check-certificate
      to the request, either just after the wget or at the end of the line.

      Reply
  • 2013-11-14 at 06:08
    Permalink

    after reading so many articals about easy_install,pip and virtualenv,this one is most usefull and clearly.Thank you very much~

    Reply
  • 2013-11-14 at 14:04
    Permalink

    To install and get working the actual Python version 3.3.2 @ up-to-date CentOS 6.4,
    you need to modify the step “Download and install Python 3.3.x”
    by adding –with-ssl:
    ./configure –with-ssl –prefix=/usr/local
    Otherwise you end up with numerous ssl related errors and stuff not working.
    (e.g. :
    /usr/local/bin/easy_install-3.3 virtualenv
    Searching for virtualenv
    Reading http://pypi.python.org/simple/virtualenv/
    Download error on http://pypi.python.org/simple/virtualenv/: unknown url type: https — Some packages may not be found!

    or
    # pip -V

    ImportError: No module named ‘_ssl’
    )

    Reply
    • 2013-12-10 at 14:21
      Permalink

      This also happen if you do not have openssl-devel package:

      yum install openssl-devel

      Reply
  • 2013-11-21 at 08:11
    Permalink

    thank you first.
    And i have another question,since when we use virtualenv,we always use it like this way:/usr/local/bin/virtualenv-XXXX or /usr/local/bin/virtualenv-yyyy rather than simply use /usr/local/bin/virtualenv,why not remove or rename /usr/local/virtualenv?
    this file may bring some confusion because of the version information.

    Reply
  • 2013-11-27 at 03:35
    Permalink

    Running perfectly well.
    Thanks a lot, Daniel.

    Reply
  • Pingback: I ran into Python | Private Dock

  • Pingback: Monday, December 2nd, 2013 | DayByDayFindings

  • 2013-12-04 at 01:52
    Permalink

    Hello,
    where does distribute download? in /usr/local/?
    After install distribute, Can I delete distribute folder?

    Thanks

    Reply
  • Pingback: How to install Python 2.7.3 on CentOS 6.2 | yetaocloud

  • 2013-12-19 at 17:55
    Permalink

    Hi Daniel,
    I have got an HTTPSHandler error while installing packages using pip as with the following stacktrack,
    on ubuntu10.04 with python2.7

    ———————————desktop:~$ pip install Django==1.3
    Traceback (most recent call last):
    File “/home/gaurav/.genv/bin/pip”, line 9, in
    load_entry_point(‘pip==1.4.1’, ‘console_scripts’, ‘pip’)()
    .
    .
    .
    . from urllib2 import (Request, urlopen, URLError, HTTPError,
    ImportError: cannot import name HTTPSHandler

    Help to come out from this error, will be thankful to you 🙂

    Reply
  • 2013-12-23 at 10:06
    Permalink

    http://namhuy.net/908/how-to-install-iftop-bandwidth-monitoring-tool-in-rhel-centos-fedora.html

    Requirements:
    libpcap: module provides a user-level network packet capture information and statistics.
    libncurses: is a API programming library that enables programmers to provide text-based interfaces in a terminal.
    gcc: GNU Compiler Collection (GCC) is a compiler system produced by the GNU Project supporting various programming languages.

    Install libpcap, libnurses, gcc via yum
    yum -y install libpcap libpcap-devel ncurses ncurses-devel gcc

    Download and Install iftop
    wget http://www.ex-parrot.com/pdw/iftop/download/iftop-0.17.tar.gz
    ./configure
    make
    make install

    Reply
  • Pingback: Bruteforce Facebook Login with Python Script | franx47

  • 2014-01-09 at 16:49
    Permalink

    Excellent and very helpful article, thank you!

    BTW, tried to follow the procedure Today on CentOS 6.4 64bi and encountered error “… OSError: Command /home/swamydkv/py_virenv/test/bin/python3 -c “import sys, pip; pip…ll”] + sys.argv[1:])” setuptools pip failed with error code 1″ described at following URL:

    http://askubuntu.com/questions/400343/trying-to-create-a-python-virtual-environment-but-getting-oserror

    It looks we have a bug in current version of setuptools, so fix was to downgrade virtualenv to 1.10.1 using following command:
    easy_install “virtualenv<1.11"

    Hope this info will be helpful if someone runs in the same issue I had Today J.

    Reply
  • 2014-02-12 at 15:30
    Permalink

    Thanks for the post… and for the update to the recently-released python 3.3.4. I have used this page as reference a few times in the past and today, while showing it to a friend that wanted to upgrade python on an older server, I saw you had the updated instructions for 3.3.4, which got released just 3 days ago.

    Reply
    • 2014-02-12 at 15:35
      Permalink

      I will update the post with info about installing Setuptools later tonight. Distribute is deprecated.

      Reply
  • 2014-02-16 at 19:22
    Permalink

    If this is only for development, isn’t it better to avoid system wide installation by using –prefix=$HOME/.fakeroot/usr?

    Reply
    • 2014-02-16 at 19:38
      Permalink

      I think that is a personal preference thing. If I have root access I usually install things like this system-wide even if it is only used for development. One reason to do this is that I want to keep my development/staging environment as close as possible to the deployment environment.

      When I don’t have root access I usually install in $HOME/Python-x.y.z to keep it fully separated from other user-installed apps. I don’t even add that bin dir to the path because I just need it once when I set up a new isolated environment with virtualenv or pyvenv.

      Reply
  • 2014-02-24 at 23:58
    Permalink

    Hi Daniel,

    Many, many thanks for what has to be the best tutorial on the web for installing Python 2.7 and 3.3 on CentOS 6. I tried it and it worked fine.

    I don’t know if you’ve run into this, however, and if you did I’d appreciate any insight you have to it. After installing Python 3.3 according to your instructions, then doing pip install’s of the following within the virtualenv of my33project:

    numpy
    scipy
    matplotlib
    ipython
    pandas
    sympy
    nose

    I get the following error when I run “ipython3 –pylab”:

    [TerminalIPythonApp] WARNING | GUI event loop or pylab initialization failed

    Here are the errors pointed to with the warning:

    TclError Traceback (most recent call last)
    /usr/local/lib/python3.3/site-packages/IPython/core/shellapp.py in (key)
    221 shell = self.shell
    222 if self.pylab:
    –> 223 enable = lambda key: shell.enable_pylab(key, import_all=self.pylab_import_all)
    224 key = self.pylab
    225 elif self.matplotlib:

    /usr/local/lib/python3.3/site-packages/IPython/core/interactiveshell.py in enable_pylab(self, gui, import_all, welcome_message)
    2918 from IPython.core.pylabtools import import_pylab
    2919
    -> 2920 gui, backend = self.enable_matplotlib(gui)
    2921
    2922 # We want to prevent the loading of pylab to pollute the user’s

    /usr/local/lib/python3.3/site-packages/IPython/core/interactiveshell.py in enable_matplotlib(self, gui)
    2884 # Now we must activate the gui pylab wants to use, and fix %run to take
    2885 # plot updates into account
    -> 2886 self.enable_gui(gui)
    2887 self.magics_manager.registry[‘ExecutionMagics’].default_runner =
    2888 pt.mpl_runner(self.safe_execfile)

    /usr/local/lib/python3.3/site-packages/IPython/terminal/interactiveshell.py in enable_gui(gui, app)
    306 from IPython.lib.inputhook import enable_gui as real_enable_gui
    307 try:
    –> 308 return real_enable_gui(gui, app)
    309 except ValueError as e:
    310 raise UsageError(“%s” % e)

    /usr/local/lib/python3.3/site-packages/IPython/lib/inputhook.py in enable_gui(gui, app)
    526 e = “Invalid GUI request %r, valid ones are:%s” % (gui, list(guis.keys()))
    527 raise ValueError(e)
    –> 528 return gui_hook(app)
    529

    /usr/local/lib/python3.3/site-packages/IPython/lib/inputhook.py in enable_tk(self, app)
    322 if app is None:
    323 import tkinter
    –> 324 app = tkinter.Tk()
    325 app.withdraw()
    326 self._apps[GUI_TK] = app

    /usr/local/lib/python3.3/tkinter/__init__.py in __init__(self, screenName, baseName, className, useTk, sync, use)
    1798 baseName = baseName + ext
    1799 interactive = 0
    -> 1800 self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
    1801 if useTk:
    1802 self._loadtk()

    TclError: no display name and no $DISPLAY environment variable

    Would you know how to fix this?

    Reply
    • 2014-02-25 at 00:58
      Permalink

      These look like standard messages from an X-enabled application unable to open the display. I don’t use ipython, but I believe it has a command-line option to run in the terminal.
      If you ssh’d to the machine where you’re running ipython, you may have forgotten to use the ssh option -X or -Y.

      Reply
      • 2014-02-25 at 02:28
        Permalink

        Hi Dave, and thanks for the reply.

        X11 Forwarding is already enabled through the sshd_config file. I don’t see what starting the shell session with the -X or -Y option would do above that.

        Reply
  • 2014-02-26 at 20:51
    Permalink

    Daniel, you don’t have any insight into the problem I am experiencing above?

    Reply
    • 2014-02-26 at 21:05
      Permalink

      No, not really. Have you tried to launch any other X applications to verify that forwarding works?

      Reply
  • 2014-02-27 at 02:02
    Permalink

    Another blind stab: it looks like ipython3 is doing its work in subprocesses. Perhaps those are running login shells which unset or otherwise disturb the DISPLAY setting ? But clearly Daniel’s question is the key.
    Can xclock, xlogo, xload, or any other X application run ?

    Reply
  • 2014-03-09 at 01:51
    Permalink

    before i could successfully do:
    python2.7 ez_setup.py

    i had to:
    yum install zlib-devel

    then redo the python install:
    make&&make altinstall

    then it works

    Reply
    • 2014-03-09 at 01:56
      Permalink

      That is part of the preparations step of the guide. Are my instructions wrong or did you not follow the guide?

      Reply
  • 2014-03-18 at 16:24
    Permalink

    Hi,

    In Python 3.3, can you add installation of the xz-devel package? It is needed for lzma module

    Reply
    • 2014-03-19 at 21:03
      Permalink

      Thank you, I tried this and it works just fine for both 3.3 and the recently released 3.4. I’ll include your recommendation in my next update.

      Reply
  • 2014-03-18 at 17:05
    Permalink

    If you’re getting permission errors when running easy_install and pip, but sudo’ing gives you ‘command not found’ errors, the path for the superuser is different from yours. Wrap the command in a $(which commandname) before passing into sudo so it looks on the absolute path:

    sudo $(which pip2.7) install virtualenv

    Reply
  • Pingback: my emacs and linux engineering note. | nova0302

  • Pingback: How to install python 2.7 on CentOS 6.5 | nova0302

  • 2014-04-09 at 03:57
    Permalink

    Tahnks!, It’s very useful article

    Reply
  • 2014-04-12 at 00:50
    Permalink

    what happens if python is upgraded to 2.7 and 2.7 has to be run the same time as yum. That is:

    /usr/bin/yum -d 0 -e 0 -y install openstack-keystone

    This command also checks that the package openstack-keystone needs python 2.7 libraries
    and throws error if they are not found, but on the same time yum needs python2.6.x

    Can these 2 demands live together ?

    Reply
    • 2014-04-12 at 11:08
      Permalink

      First of all you don’t actually upgrade Python by following the instructions in this guide, you merely install a new version side-by-side. I have no idea what happens if Python 2.7 is called from a script running under Python 2.6. If PYTHONPATH is mangled then all sorts of (not so) funny things might happen. Why not do a quick test in a VM (or on a VPS that charges by the minute or hour)? I don’t know enough about OpenStack to verify if Keystone works if I could get it to install, so I would just be wasting my time doing it.

      Reply
  • 2014-04-23 at 11:12
    Permalink

    Dear Daniel,
    Why do i get this error when trying to execute this command
    python3.4 ez_setup.py


    File “/usr/local/lib/python3.4/zipfile.py”, line 614, in _get_decompressor
    return zlib.decompressobj(-15)
    AttributeError: ‘NoneType’ object has no attribute ‘decompressobj’

    ?
    Best regards

    Reply
      • 2015-02-09 at 12:15
        Permalink

        Hi, I have the same problem. I installed zlib-devel AFTER building python. How can I proceed now with the pip installation?

        Reply
  • 2014-05-05 at 09:08
    Permalink

    Thanks for the post Daniel! Very helpful

    Reply
  • Pingback: Quora

  • 2014-05-16 at 04:27
    Permalink

    hi all, I am trying to install PySide on Python3.3 (CentOS) – have tried either pip install PySide or easyinstall-3.3 PySide but both fails with error message – Failed to find cmake. Please specify the path to cmake with –cmake parameter.

    if i used yum, install seems to work but Python3.3 can’t detect it.

    any advice? thank you!

    Reply
  • 2014-05-16 at 05:55
    Permalink

    Ok i gotten further. installed cmake via yum and that got me further.
    however, now pyside fails install with error compiling shiboken – make: *** [all] Error 2

    still googling trying to figure out whats wrong

    Reply
  • Pingback: Python 2.7 and Python 3.3 on CentOS 6 Reliable Penguin - Blog

  • 2014-06-01 at 22:41
    Permalink

    For 64 bit systems, add the line:

    /usr/local/lib64

    to /etc/ld.so.conf to make it look like the following.

    include ld.so.conf.d/*.conf
    /usr/local/lib
    /usr/local/lib64

    This solves the potential error of:

    problem loading shared libraries: libpython3.4m.so.1.0: cannot open shared object file: No such file or directory

    Reply
  • 2014-06-06 at 20:28
    Permalink

    Installed correctly.

    When I run Python will work —> /usr/local/bin/python2.7

    ” Python 2.7.6 (default, Jun 6 2014, 11:02:54)
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
    Type “help”, “copyright”, “credits” or “license” for more information.
    >>>

    More so when I run, does not work -> /usr/bin/python2.7

    ” -bash: /usr/bin/python2.7: No such file or directory ”

    How do I run the 2 commands? For I have a server that works.

    Help me please.

    Reply
  • 2014-06-25 at 18:54
    Permalink

    I had a hard time interpreting what you meant about whether or not to install unicode support. I would like to recommend that you change:

    “Unless you have very specific reasons you should configure Python 3.2 and earlier to enable UTF-32 support.”

    to

    “Unless you have very specific reasons, you should configure Python 3.2 and earlier to enable UTF-32 support.”

    I think the comma will make a mental pause that can help separate the if/then structure.

    Reply
  • 2014-06-27 at 02:52
    Permalink

    A straightforward review of that process (for Python 3.2.2!)…

    —————————————————————————-

    * Install Python 3.2.2 (CentOS 6.5):

    [Ref.: http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos/%5D

    ————————–

    – In order to compile Python you must first install the development tools and a few
    extra libs. The extra libs are not strictly needed to compile Python but without
    them your new Python interpreter will be quite useless

    yum groupinstall “Development tools”
    yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

    ————————–

    – Here are the commands to download, compile and install Python

    wget http://python.org/ftp/python/3.2.2/Python-3.2.2.tar.xz –no-check-certificate
    tar xf Python-3.2.2.tar.xz
    cd Python-3.2.2
    ./configure –prefix=/usr/local –enable-shared LDFLAGS=”-Wl,-rpath /usr/local/lib”
    make && sudo make altinstall

    ————————–

    – After running the commands above your newly installed Python interpreter will
    be available as /usr/local/bin/python3.2

    /usr/local/bin/python3.2

    ————————–

    – Download and install Setuptools + pip

    cd ~/Downloads
    wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
    sudo /usr/local/bin/python3.2 ez_setup.py
    sudo /usr/local/bin/easy_install-3.2 pip

    ————————–

    – Create your isolated Python 3.2 environment

    sudo /usr/local/bin/pip3.2 install virtualenv
    sudo /usr/local/bin/virtualenv ~/virtenv3.2 (maybe /usr/local/bin/virtualenv-3.2)
    cd ~/virtenv3.2
    source bin/activate
    python –version (To check version)

    —————————————————————————-

    Many thanks Daniel Eriksson! You awesome!

    —————————————————————————-

    https://github.com/eduardolucioac/groovim

    GrooVim – Vi IMproved’n’GrooVIed!

    Reply
  • 2014-06-27 at 12:23
    Permalink

    I could not use matplotlib after I install python 2.7. All the other packages work well. And matplotlib works well with python 2.6 (the system default one). When I import gtk or import pygtk, it shows I don’t have those modules. Have any solution?

    Reply
  • 2014-07-03 at 21:16
    Permalink

    Python.org now forces https, and that wget command no longer works as-is:

    $ wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
    –2014-07-03 19:10:25– http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
    Resolving python.org… 140.211.10.69
    Connecting to python.org|140.211.10.69|:80… connected.
    HTTP request sent, awaiting response… 301 Moved Permanently
    Location: https://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz [following]
    –2014-07-03 19:10:30– https://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
    Connecting to python.org|140.211.10.69|:443… connected.
    ERROR: certificate common name “*.python.org” doesn’t match requested host name “python.org”.
    To connect to python.org insecurely, use ‘–no-check-certificate’.

    Suggest adding “–no-check-certificate” to the instructions.

    Reply
  • Pingback: Python, Flask, WSGI 설정 삽질 ㅠ on CentOS 6 | I'm Nova.

  • 2014-07-12 at 20:52
    Permalink

    Great Post Extremely Helpful !!!!
    Thanks
    Cheryl

    Reply
  • 2014-07-16 at 18:16
    Permalink

    Instead of adding a line to /etc/ld.so.conf, I think it’s a better idea to create a separate .conf file into the /etc/ld.so.conf.d.
    That would make possible to do it easier (with just one command), it can be done several times without worrying about duplicate lines and it’s more clean. For instance:
    echo “/usr/local/lib” > /etc/ld.so.conf.d/python-alt.conf

    And it’s also easier to revert:
    rm /etc/ld.so.conf.d/python-alt.conf

    Reply
  • Pingback: Linux tricks | Pearltrees

  • 2014-08-17 at 13:21
    Permalink

    Hi this looks like a perfect solution to my problem but for some reason when trying to extract either of the pre compiled downloads i get the following error :/

    root@pancakes [~]# tar xf Python-2.7.6.tar.xz
    tar: This does not look like a tar archive
    tar: Skipping to next header
    tar: Archive contains obsolescent base-64 headers
    tar: Read 6968 bytes from Python-2.7.6.tar.xz
    tar: Error exit delayed from previous errors

    Reply
    • 2014-08-17 at 15:12
      Permalink

      Fixed, Just had an old version or tar.

      Reply
      • 2014-08-17 at 21:22
        Permalink

        Yes, new version of tar knows how to unpack both gzip, bzip2 and xz archives without having to pass it as a command line option.

        Reply
  • Pingback: Installing Grunt on CentOS 5.10 | Josh's Blog

  • 2014-09-08 at 20:35
    Permalink

    Hello All,

    I’m new to python world and getting some error while installing python 2.7.6, please refer below for more details

    Error Log :-
    ===============
    checking whether the C compiler works… no
    configure: error: in `/home/hadoop/hadoop/Python-3.3.5′:
    configure: error: C compiler cannot create executables

    —————————–

    After saw the above error I had install C compilar and try again, but the result is same

    command used for installation —> yum install compat-gcc-34-g77

    Version information
    ==================
    hostname = localhost.localdomain
    uname -m = i686
    uname -r = 2.6.32-358.el6.i686
    uname -s = Linux
    uname -v = #1 SMP Thu Feb 21 21:50:49 UTC 2013
    /usr/bin/uname -p = unknown
    /bin/uname -X = unknown

    /bin/arch = i686
    /usr/bin/arch -k = unknown

    Please help me to solve this problem.

    Thanks & Regards,

    Satz.

    Reply
  • 2014-09-30 at 12:06
    Permalink

    How many comments?? Thanks for this. I used this to help me install Python 2.7 on and AWS instance as the new S3 tools need 2.7 and yum needs 2.6.

    Reply
  • 2014-10-19 at 00:50
    Permalink

    I am running into the following error while executing “python2.7 ez_setup.py”

    Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-6.1.zip
    Traceback (most recent call last):
    File “ez_setup.py”, line 332, in
    sys.exit(main())
    File “ez_setup.py”, line 327, in main
    downloader_factory=options.downloader_factory,
    File “ez_setup.py”, line 287, in download_setuptools
    downloader(url, saveto)
    File “ez_setup.py”, line 224, in download_file_wget
    _clean_check(cmd, target)
    File “ez_setup.py”, line 169, in _clean_check
    subprocess.check_call(cmd)
    File “/usr/local/lib/python2.7/subprocess.py”, line 504, in check_call
    raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command ‘[‘wget’, ‘https://pypi.python.org/packages/source/s/setuptools/setuptools-6.1.zip’, ‘–quiet’, ‘–output-document’, ‘/root/setuptools-6.1.zip’]’ returned non-zero exit status 1

    Any suggestions ?

    Reply
    • 2014-10-19 at 12:56
      Permalink

      Figured out the issue, apparently we need to pass –insecure option to the script at the time of execution:

      python2.7 ez_setup.py –insecure

      Reply
  • 2014-10-27 at 21:54
    Permalink

    Thank you so much for this info. very useful!!

    Reply
  • 2014-11-03 at 21:45
    Permalink

    I followed your step to do a new python install in centos7 but ran into trouble at group install step and make step.

    at the group install step:

    No such command: Development tools. Please use /bin/yum –help
    [chizzo@localhost ~]$ sudo yum groupinstall “Development Tools”
    Loaded plugins: fastestmirror, langpacks
    There is no installed groups file.
    Maybe run: yum groups mark convert (see man yum)
    Loading mirror speeds from cached hostfile
    * base: mirror.pac-12.org
    * extras: centos.tcpdiag.net
    * updates: mirrors.sonic.net
    Warning: Group development does not have any packages to install.
    Maybe run: yum groups mark install (see man yum)
    No packages in any requested group available to install or update

    I just moved on and ran the next command and it installed a bunch of stuff.
    But then at the make step:

    [chizzo@localhost Python-3.3.5]$ sudo make && make altinstall
    [sudo] password for chizzo:
    running build
    running build_ext
    running build_scripts
    copying and adjusting /home/chizzo/tmp/Python-3.3.5/Tools/scripts/pydoc3 -> build/scripts-3.3
    copying and adjusting /home/chizzo/tmp/Python-3.3.5/Tools/scripts/idle3 -> build/scripts-3.3
    copying and adjusting /home/chizzo/tmp/Python-3.3.5/Tools/scripts/2to3 -> build/scripts-3.3
    copying and adjusting /home/chizzo/tmp/Python-3.3.5/Tools/scripts/pyvenv -> build/scripts-3.3
    changing mode of build/scripts-3.3/pydoc3 from 644 to 755
    changing mode of build/scripts-3.3/idle3 from 644 to 755
    changing mode of build/scripts-3.3/2to3 from 644 to 755
    changing mode of build/scripts-3.3/pyvenv from 644 to 755
    renaming build/scripts-3.3/pydoc3 to build/scripts-3.3/pydoc3.3
    renaming build/scripts-3.3/idle3 to build/scripts-3.3/idle3.3
    renaming build/scripts-3.3/2to3 to build/scripts-3.3/2to3-3.3
    renaming build/scripts-3.3/pyvenv to build/scripts-3.3/pyvenv-3.3
    /usr/bin/install -c python /usr/local/bin/python3.3m
    /usr/bin/install: cannot create regular file ‘/usr/local/bin/python3.3m’: Permission denied
    make: *** [altbininstall] Error 1
    [chizzo@localhost Python-3.3.5]

    The contents of /usr/local/ do not show any install.
    not sure what to do other than google around…

    Reply
    • 2014-11-21 at 17:15
      Permalink

      Running separate sudos seemed to work for me:
      sudo make
      sudo make altinstall

      Reply
    • 2014-12-24 at 11:07
      Permalink

      mc,

      Did you ever resolve issue you mentioned above.

      I would recommend running following as root instead of using sudo. That solved my issue…

      sudo su

      add ” /usr/local/lib ” to /etc/ld.so.conf

      cat /etc/ld.so.conf
      include ld.so.conf.d/*.conf
      /usr/local/lib

      ldconfig

      cd /home/chizzo/tmp/Python-3.3.5

      ./configure –prefix=/usr/local –enable-unicode=ucs4

      make && make altinstall

      Reply
  • Pingback: Fix Ez_setup Syntax Error Windows XP, Vista, 7, 8 [Solved]

  • Pingback: Fix Python Ez_setup.py Error Windows XP, Vista, 7, 8 [Solved]

  • Pingback: Fix Blender Error Python Auto-execution Disabled Windows XP, Vista, 7, 8 [Solved]

  • 2014-12-05 at 09:45
    Permalink

    Excellent howto! Thank you for sharing these easy steps to have more version of python running on the same box.

    Reply
  • Pingback: How to get W3af 1.6 running on a CentOS 6.5 system with Python 2.7.6 | Tim Blog

  • 2014-12-08 at 17:26
    Permalink

    To run pydoc with correct python version, I found this works:
    /usr/local/bin/python2.7 -m pydoc

    $ type pydoc
    pydoc is aliased to `python -m pydoc’

    So I guess could re-alias pydoc to use python2.7.

    Reply
  • Pingback: Fix Configure Error Zlib Not Installed Centos Windows XP, Vista, 7, 8 [Solved]

  • 2014-12-14 at 01:15
    Permalink

    Hi

    Great stuff man!

    I’m trying to run django in the virtualenv and that’s what I’m getting
    Traceback (most recent call last):
    File “manage.py”, line 8, in
    from django.core.management import execute_from_command_line
    ImportError: No module named django.core.management

    any thoughts?

    TIA

    Reply
  • Pingback: Fix Ez Setup Py Error Windows XP, Vista, 7, 8 [Solved]

  • 2014-12-24 at 10:50
    Permalink

    I followed instructions as listed. I choose second option for compiling Python as a shared library:

    added ” /usr/local/lib ” to /etc/ld.so.conf

    cat /etc/ld.so.conf
    include ld.so.conf.d/*.conf
    /usr/local/lib

    sudo ldconfig
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cd ( to go to my home directory )

    sudo mkdir Downloads

    cd Downloads
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    sudo wget http://python.org/ftp/python/2.7.9/Python-2.7.9.tar.xz
    sudo wget http://python.org/ftp/python/3.4.2/Python-3.4.2.tar.xz

    tar xf Python-2.7.9.tar.xz
    tar xf Python-3.4.2.tar.xz

    ls -ld Python*
    drwxr-xr-x 18 sgadmn sgadmn 4096 Dec 23 17:47 Python-2.7.9/
    -rw-rw-r– 1 sgadmn sgadmn 12164712 Dec 10 09:08 Python-2.7.9.tar.xz
    drwxr-xr-x 16 sgadmn sgadmn 4096 Dec 23 18:08 Python-3.4.2/
    -rw-rw-r– 1 sgadmn sgadmn 14223804 Oct 8 01:25 Python-3.4.2.tar.xz

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cd Python-2.7.9

    sudo ./configure –prefix=/usr/local –enable-unicode=ucs4

    sudo make && make altinstall

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cd ../Python-3.4.2

    sudo ./configure –prefix=/usr/local –enable-unicode=ucs4

    sudo make && make altinstall

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    I got following error when running ” sudo make && make altinstall ”

    Python build finished, but the necessary bits to build these modules were not found:
    bsddb185 dl imageop
    sunaudiodev
    To find the necessary bits, look in setup.py in detect_modules() for the module’s name.

    running build_scripts
    creating build/scripts-2.7
    copying and adjusting /home/sgadmn/Downloads/Python-2.7.9/Tools/scripts/pydoc -> build/scripts-2.7
    copying and adjusting /home/sgadmn/Downloads/Python-2.7.9/Tools/scripts/idle -> build/scripts-2.7
    copying and adjusting /home/sgadmn/Downloads/Python-2.7.9/Tools/scripts/2to3 -> build/scripts-2.7
    copying and adjusting /home/sgadmn/Downloads/Python-2.7.9/Lib/smtpd.py -> build/scripts-2.7
    changing mode of build/scripts-2.7/pydoc from 644 to 755
    changing mode of build/scripts-2.7/idle from 644 to 755
    changing mode of build/scripts-2.7/2to3 from 644 to 755
    changing mode of build/scripts-2.7/smtpd.py from 644 to 755
    /usr/bin/install -c -m 644 ./Tools/gdb/libpython.py python-gdb.py
    /usr/bin/install -c python /usr/local/bin/python2.7
    /usr/bin/install: cannot create regular file `/usr/local/bin/python2.7′: Permission denied
    make: *** [altbininstall] Error 1

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    So I went back and ran everything again as root:

    sudo su

    cd /home/my-homedir/Downloads/Python-2.7.9

    ./configure –prefix=/usr/local –enable-unicode=ucs4

    make && make altinstall

    cd /home/my-homedir/Downloads/Python-3.4.2

    ./configure –prefix=/usr/local –enable-unicode=ucs4

    make && make altinstall

    cd /usr/local/bin

    ls -ld py*
    -rwxr-xr-x 1 root root 84 Dec 23 17:16 pydoc*
    -rwxr-xr-x 1 root root 84 Dec 23 18:09 pydoc3.4*
    -rwxr-xr-x 1 root root 9760 Dec 23 17:47 python2.7*
    -rwxr-xr-x 1 root root 1687 Dec 23 17:47 python2.7-config*
    -rwxr-xr-x 2 root root 12618 Dec 23 18:08 python3.4*
    -rwxr-xr-x 2 root root 12618 Dec 23 18:08 python3.4m*
    -rwxr-xr-x 1 root root 3011 Dec 23 18:09 python3.4m-config*
    -rwxr-xr-x 1 root root 236 Dec 23 18:09 pyvenv-3.4*

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    I got following errors when running python:

    > python2.7
    python2.7: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

    > python3.4
    python3.4: error while loading shared libraries: libpython3.4m.so.1.0: cannot open shared object file: No such file or directory

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Ran following as root, not use sudo ldconfig to ensure /usr/local/lib path is recognized

    ldconfig

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cd /usr/local/bin

    ldd python2.7
    linux-vdso.so.1 => (0x00007fff9a151000)
    libpython2.7.so.1.0 => /usr/local/lib/libpython2.7.so.1.0 (0x00007fb77d4d0000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fb77d2b3000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007fb77d0ae000)
    libutil.so.1 => /lib64/libutil.so.1 (0x00007fb77ceab000)
    libm.so.6 => /lib64/libm.so.6 (0x00007fb77cc27000)
    libc.so.6 => /lib64/libc.so.6 (0x00007fb77c892000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fb77d8bd000)

    ldd python3.4
    linux-vdso.so.1 => (0x00007fff799d9000)
    libpython3.4m.so.1.0 => /usr/local/lib/libpython3.4m.so.1.0 (0x00007f2fa84a8000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f2fa828b000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f2fa8086000)
    libutil.so.1 => /lib64/libutil.so.1 (0x00007f2fa7e83000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f2fa7bff000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f2fa786a000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f2fa895e000)

    Both paths are now seen:

    libpython2.7.so.1.0 => /usr/local/lib/libpython2.7.so.1.0 (0x00007fb77d4d0000)
    libpython3.4m.so.1.0 => /usr/local/lib/libpython3.4m.so.1.0 (0x00007f2fa84a8000)

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Everything working as expected:

    python2.7
    Python 2.7.9 (default, Dec 23 2014, 17:47:28)
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
    Type “help”, “copyright”, “credits” or “license” for more information.

    python3.4
    Python 3.4.2 (default, Dec 23 2014, 18:07:56)
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux
    Type “help”, “copyright”, “credits” or “license” for more information.
    >>>

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Thanks Daniel Eriksson for creating this document.

    Thanks everyone else for your posts.

    -sg

    Reply
  • Pingback: How to install Python 3.4 on CentOS |

  • 2015-01-06 at 03:55
    Permalink

    Thanks for the informative write up. I just installed python3.4 on my CentOS 6.4 server and your steps worked perfectly except I used newer versions of coarse.

    Thanks, Again

    Reply
  • 2015-02-17 at 12:00
    Permalink

    Thanks a Lot it worked and saved me 2 days of digging on Centos 7.

    Reply
  • Pingback: Amazon Linuxにpipをインストール(pip3は失敗でyumで環境作るのが良いらしい)-はじめてのAWS | kazsoga(曽我一弘)ブログ

  • 2015-03-15 at 02:06
    Permalink

    This is how instructions should be. They are complete, they are precise, and they explain why I am going through all of these steps. They even talk about alternatives. Thanks, Daniel!

    Reply
  • 2015-03-24 at 20:55
    Permalink

    This is an extremely straightforward and easy to follow explanation. I’m a python newbie and I was up and running within minutes of reading this. It’s much appreciated. Thank you!

    Reply
  • 2015-03-26 at 21:54
    Permalink

    If LDFLAGS appears to be confusing ./configure as so:

    configure: error: C compiler cannot create executables
    See `config.log’ for more details

    an alternate way to communicate the Python library path to the run-time linker worked for me:

    ./configure –prefix=/usr/local –enable-shared
    LD_RUN_PATH=/usr/local/lib make
    sudo make install

    The LDFLAGS=’Wl,-rpath /usr/local/lib’ method given in the tutorial worked for me until very recently (though I had to create /usr/local/lib first, as pointed out in a page linked to in a comment above), but with a recent CentOS 6 update that stopped working

    This was for Python-3.4.3 on CentOS 6.

    Reply
  • Pingback: CentOS 6.5にPython 2.7をインストールしApacheで使用 | Akashic Records

  • 2015-04-18 at 02:14
    Permalink

    hi daniel,

    i got python2.7 installed on my fedora core 3 machine as alternative python using your doc

    But i m still getting same error yum module is not present

    System python version is still 2.3.4

    please help

    Thanks,
    cedraj

    Reply
  • Pingback: How to install Python 2.7 and Python 3.3 on CentOS 6 | 小狐濡尾

  • Pingback: Installation of python 2.7 on RHEL CentOS | millionzeros

  • Pingback: Setup of Development environment for Python 2.7 on Centos/Redhat 6 | ifconfigblog

  • 2015-05-25 at 08:29
    Permalink

    I carefully followed the instructions and have a good install of the two versions 2.7.6 and 3.4.3 – and I installed. I chose not to edit the so.conf file. I can get the version of each using the python3.4 -V and python2.7 -V. I installed PIP and even then installed Django with a succesful install. I installed virtualenv without error, as in here:

    pip2.7 install virtualenv
    virtualenv-2.7 my27project

    But when I type virtualenv-2.7 my27project I get that virtualenv-2.7 is not found. What do I do?

    Also – pyenv-3.4 is not found and pyenv without the suffix is not found.

    What can I do to correct these so I can test my django installation?

    Thanks

    Reply
  • 2015-05-25 at 17:49
    Permalink

    Made this work by using pyvenv-3.4 and activating the virtual environment before installing django. That’s all well and good. I do have one remaing question – when I want to publish and use my django application how do I apply this virtual environemnt so at runtime apache uses this virtual environemnt to find my python 3.4 and use that?

    Reply
  • Pingback: 给CentOS 6.5上的Python 2.6.6通过easy install安装argparse模块 | sw32技术博客

  • Pingback: 零一积流 | 学习知识 分享经验 » CentOS上安装Django

  • 2015-07-01 at 15:16
    Permalink

    Hi –
    Is it fair to expect this instructions to work well on RHEL 6.x
    Best

    Reply
  • 2015-08-15 at 13:33
    Permalink

    I’m a noob so I’ve been doing my fair share of install/reinstall lately , and now that I’ve come across this tutorial it won’t be because I broke Python the next time! This is excellent, thank you very much. Well explained, well guided, and complete. I changed a few things like 2.7.10 and 3.4.3 , and using dnf instead of yum, and it still went perfect.

    Reply
  • 2015-08-17 at 23:10
    Permalink

    In the Shared Library section, the line with LDFLAGS=”-Wl,-rpath /usr/local/lib” can be rendered to include a dash. For me it appeared as “LD- FLAGS=”. Copy in firefox actually puts the correct text into the clipboard, but that’s just confusing! Perhaps put it in a block?

    Editing ld.so.conf gives me nightmares.

    Regarding another comment above, I'm not sure that setting LD_RUN_PATH= gets recorded in the compiled binary the way -rpath does.

    Reply
    • 2015-08-17 at 23:12
      Permalink

      The markup engine ate part of my comments: There was a newline in the middle of LDFLAGS, and I suggested putting the mis-rendered line in a “code block”.

      Reply
    • 2017-02-07 at 00:59
      Permalink

      That is strange. I tried viewing the article in both IE, Chrome and Firefox and for me it looks OK in all three. I have just updated the guide and completely removed the ldconfig instructions. Most people should probably compile the search path into the executable anyway, so no need to include an optional method here. I assume anyone that needs the path to not be hardcoded also knows how to properly set up ldconfig search paths.

      Reply
  • 2015-08-18 at 21:06
    Permalink

    I would add a step to ‘strip’ the shared library which makes it much smaller and matches the vendor implementation (at least RedHat). ie

    strip /usr/local/lib/libpython2.7.so.1.0

    Reply
    • 2017-02-07 at 00:55
      Permalink

      Thank you for the suggestion. I have updated the guide to include instructions for stripping out the symbols.

      Reply
  • Pingback: » Python:Install python 2.6 in CentOS

  • 2015-09-09 at 15:25
    Permalink

    Thanks for posting this it has been extremely useful. Can any of the initial yum installs be safely removed once the compile is complete?

    Reply
  • Pingback: Python:building Python from source with zlib support – IT Sprite

  • Pingback: Python:ImportError: No module named psycopg2 – IT Sprite

  • Pingback: Python:How to ignore local python when building python from source – IT Sprite

  • Pingback: Let’s Encrypt on VestaCP with CentOS 6 » Kodiak’s Korner - My Little Corner of the Net

  • Pingback: GStreamer编译 – 突围

  • 2016-02-16 at 11:16
    Permalink

    Hi Daniel, Your blog was very helpful and I had followed these steps to install Django 1.7 inside a virtualenv (using Python 2.7.8) on CentOS 6.7. However, I recently tried to upgrade Django to version 1.8.8 using pip2.7 install –upgrade django==1.8.8 and consistently hit a segmentation fault after the package is downloaded. Any ideas as to what might be going wrong?

    Reply
  • Pingback: python套件 pbh5tools: PacBio rawdata 格式轉換 | Gene

  • Pingback: Linux系统:Python2.6和Python2.7同时存在 | Gene

  • 2016-03-09 at 23:18
    Permalink

    Useful instructions that are still being used. Thanks!

    Reply
  • Pingback: Use Vagrant to Manage an OEL6 Virtual Machine | Connor Johnson

  • 2016-04-07 at 19:38
    Permalink

    Thanks Daniel! This is very useful and detail explanation. It saves me a lot of time.

    Reply
  • 2016-04-14 at 09:39
    Permalink

    Thank you, it works for py2.7.11 & py3.5.1 on CentOS Minimal 6.6. Well, except that py3.5.1 ships with setuptools and pip already.

    Here are the last few lines of sudo make && sudo make altinstall (of py3.5.1) ‘s output:

    ……
    Ignoring indexes: https://pypi.python.org/simple
    Collecting setuptools
    Collecting pip
    Installing collected packages: setuptools, pip
    Successfully installed pip-7.1.2 setuptools-18.2

    Reply
    • 2017-02-07 at 00:54
      Permalink

      You are absolutely right. I have now updated the guide to use get-pip.py script that installs/upgrades pip, setuptools and wheel.

      Reply
  • Pingback: Centos 6.4 安装 Python 2.7 | 勇气

    • 2017-02-07 at 00:53
      Permalink

      I have now updated the guide to use get-pip.py script that installs/upgrades pip, setuptools and wheel.

      Reply
  • Pingback: CENTOS 6.5 安装 Python 2.7 总结  – 赵浮云的blog

  • 2016-06-10 at 03:44
    Permalink

    Daniel, thank you for such great guide … well explained and all commands worked as expected. Not like other guides out there that only half the commands work. The only issue I found is the location of the ez_install.py file which is in another location on bitbucket. But everything else worked perfectly !!! I wish there was a guide like this to install QIIME on a Centos based HPC.

    Reply
    • 2017-02-07 at 00:52
      Permalink

      I have now updated the guide to use get-pip.py script that installs/upgrades pip, setuptools and wheel.

      Reply
  • Pingback: CENTOS 6.5 安装 Python 2.7 总结  – 赵浮云的blog-

  • Pingback: centos 6x install the Python | 我心依旧

  • 2016-09-01 at 09:39
    Permalink

    THANK YOU SO SO SO MUCH!!
    BY THE WAY, THE LINK FOR WGET SETTOOLS SHOULD BE “https://bootstrap.pypa.io/ez_setup.py”, WHICH IS SHOWN ON THE PYTHON OFFICAL WEBSITE. AND IT WORKS.

    Reply
  • 2016-09-16 at 09:09
    Permalink

    Excellent work ,Pretty easy to understand,,Thanks a lot…

    Reply
    • 2017-02-07 at 00:51
      Permalink

      I have now updated the guide to use get-pip.py script that installs/upgrades pip, setuptools and wheel.

      Reply
  • 2017-02-06 at 15:03
    Permalink

    How can I get the python2.7-devel package after I successfully installed python2.7 as you described

    Reply
  • 2017-02-23 at 15:57
    Permalink

    Wonderful site. Plenty of useful info here. I’m sending it to several pals ans also sharing in delicious. And naturally, thank you for your effort!

    Reply
  • 2017-03-05 at 11:32
    Permalink

    Thank you so much Daniel. I cannot express my gratitude enough.

    Reply
  • 2017-03-14 at 17:18
    Permalink

    in get-pip.py there is a script mentioned. tasks/generate.py Do you know where that can be found?

    Reply
  • 2017-03-24 at 18:03
    Permalink

    Upon installation and executing python2.7, I got the following error
    “error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory”

    during –configure, I tried giving in -Wl and -rpath options but got errors so skipped those and just did LDFLAGS -L/……/lib

    Most likely this is the source of this error. How to get around it?

    Reply
  • 2017-03-24 at 18:10
    Permalink

    Just few notes,

    1. the lib.so file is present at the /xxx/yyy/lib location
    2. Error I got with -Wl, -rpath xxx/yyy/lib option – “C compiler cannot create executables”

    Reply
    • 2017-03-27 at 12:30
      Permalink

      If you compile Python to use a shared library then you also need to tell it how to find the shared library. You do that either by adding proper LDFLAGS to the configure command, or by adding the lib folder to the ld.so.conf file.

      Are you running the commands as root (or with sudo)?

      Reply
  • 2017-04-07 at 03:19
    Permalink

    I updated the CentOS 6.5 to 6.8. ‘Yum’ is worked fine in CentOS 6.5. After update it shows following error.

    yum
    ‘import site’ failed; use -v for traceback
    There was a problem importing one of the Python modules
    required to run yum. The error leading to this problem was:

    No module named yum

    Please install a package which provides this module, or
    verify that the module is installed correctly.

    It’s possible that the above module doesn’t match the
    current version of Python, which is:
    2.6.6 (r266:84292, Aug 18 2016, 14:53:48)
    [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]

    If you cannot solve this problem yourself, please go to
    the yum faq at:
    http://yum.baseurl.org/wiki/Faq

    #!/usr/bin/python is not working for me.

    I read your post above and tried to install python 2.7. but i cant use yum as you said in “Preparations – install prerequisites”

    Please help me to fix this………… Thanks in Advance

    Reply
  • 2017-05-01 at 13:22
    Permalink

    Thank you very much for your guide.
    It has solved my problem.

    Reply
  • 2017-05-03 at 00:01
    Permalink

    Dan – this an awesome work. For the first time, I had to deal with a custom Python installation on RHEL v7.2. I followed these steps and accomplished the setup. Thanks for this.
    -Ravi Itha

    Reply
  • 2017-05-03 at 21:10
    Permalink

    I have very serious question. The Lego Cassette-Desk on the top — is it your creation. It’s absolutely wonderful. The accuracy! Even holes in the tape!

    Reply
  • 2017-05-17 at 13:23
    Permalink

    Hey Daniel, thanks for sharing this! And also big thanks for staying with your comments and do some enhancements to the original post – very appreciated; not many people care so much for what was published a while ago already.

    I have one question:
    In you article, you warn about to not try to install Python 2.7 on CentOS 7, since it might break the system.
    I do not see a reason this should happen following your instructions, since the default Python should not be changed. Could you please share and specify in what kind of issues you ran?

    Thanks a lot!

    Reply
    • 2017-05-17 at 13:34
      Permalink

      My fear is that you will end up with multiple executables called “python2.7” in your path, each having a different set of installed packages. Depending on the order of your path you might get strange behaviour. At least that is why I put the warning in there. I have no firm evidence that it will actually break the system, that is why I prefixed my assertion with “might”.

      Reply
    • 2017-05-17 at 13:42
      Permalink

      Also, if you follow my suggestions you will use /usr/local as the prefix, which means that the new python executables will be in /usr/local/bin that by default is part of a users path. If you use a different prefix then the risk of problems will be much lower.

      One way to completely remove the risk of problems is by building and installing Python 2.7.13 as a regular user, with your home directory as the prefix, or even “/home/[username]/Python-2.7.13” as the prefix. Presumably you want to use a virtualenv, and as soon as you have created that you no longer need easy access to the original python executable. This is how I personally run python for a couple of Django websites that I manage. The drawback is that you cannot compile python as a shared executable (at least I don’t know how to do that).

      Reply
  • 2017-05-24 at 19:10
    Permalink

    If i did install Python 2.7.12 previously using the option … LDFLAGS=”-Wl,-rpath /usr/local/lib”, won’t i have a problem if i want to install Python 3.6.1 using the same parameter as mentioned in this blog? Does it mean that i need to specify LDFLAGS=”-Wl,-rpath /usr/local/Python3.6/lib” instead to prevent a conflict of more than 1 python sharing the same /usr/local/lib ?

    Reply
    • 2017-05-24 at 18:56
      Permalink

      It is perfectly safe to have both Python 2 and Python 3 share the same /usr/local/lib location for their shared library. The shared library does not have the same name. Good luck!

      Reply
  • 2017-05-24 at 21:19
    Permalink

    Thanx a lot Daniel. Helped a lot.
    Glad I found this.

    Reply
  • 2017-05-25 at 08:01
    Permalink

    Daniel, would you possibly add an instruction to install virtualenvwrapper for 2.7.x and to use it?

    I think installation went well but I can make the following working:

    $export PROJECT_HOME=~/dev
    $export WORKON_HOME=~/envs
    $ source /usr/local/bin/virtualenvwrapper.sh (this part is throwing errors. It seems like it is confused with the system installed python2.7.5.

    This is the error message:

    virtualenvwrapper.sh: There was a problem running the initialization hooks.
    If Python could not import the module virtualenvwrapper.hook_loader,
    check that virtualenvwrapper has been installed for
    VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is
    set properly.

    Reply
    • 2017-05-25 at 08:36
      Permalink

      I don’t use virtualenvwrapper myself, but did you try setting VIRTUALENVWRAPPER_PYTHON to your custom python executable?

      Maybe something like this:
      $ export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2.7

      Reply
      • 2017-05-25 at 17:47
        Permalink

        Daniel, It worked! For those who want to use virtualenvwrapper, I will leave what I did. I assume that you have virtualenv installed using pip2.7 on CentOS 6.

        $pip2.7 install virtualenvwrapper
        $export PROJECT_HOME=~/dev
        $export WORKON_HOME=~/envs
        $ export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2.7
        $ source /usr/local/bin/virtualenvwrapper.sh

        Here is the link to the How-to guide about using Virtual Environments:
        http://python-guide-pt-br.readthedocs.io/en/latest/dev/virtualenvs/

        Thank you again for the wonderful guide.

        Reply
  • 2017-06-01 at 18:43
    Permalink

    Here is a standalone chef recipe that can be called to handles the install 3.6.1 on centos6 to /usr/local/python – in case anybody wants to automate this –python_alt_install.rb – i left your comments in.

    1 # This installs python 3.6 in an alt location so as not to break yum
    2
    3 # Install Compilers and related tools:
    4 execute ‘yum groupinstall -y “development tools”‘ do
    5 command ‘yum groupinstall -y “development tools –disableexcludes=all”‘
    6 end
    7
    8 # Install Libraries needed during compilation to enable all features of Python:
    9 %w{zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel expat-devel}.each do |pkg|
    10 package pkg do
    11 action :install
    12 end
    13 end
    14
    15 #create the install dir for python 3.6
    16 directory ‘/usr/local/python/lib’ do
    17 owner ‘root’
    18 group ‘root’
    19 mode ‘0755’
    20 recursive true
    21 action :create
    22 end
    23
    24 # Install Python 3.6.1 to /usr/local/python
    25 bash ‘install-python3.6.1’ do
    26 user ‘root’
    27 cwd ‘/opt’
    28 code <<-EOH
    29 wget http://python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
    30 tar xf Python-3.6.1.tar.xz
    31 cd Python-3.6.1
    32 ./configure –prefix=/usr/local/python –enable-shared LDFLAGS="-Wl,-rpath /usr/local/python/lib"
    33 make && make altinstall
    34 EOH
    35 not_if { ::File::exists?("/opt/Python-3.6.1.tar.xz")}
    36 end
    37
    38 # strip symbols after install from the shared library to reduce the memory footprint
    39 execute 'strip-symbols' do
    40 command 'strip /usr/local/python/lib/libpython3.6m.so.1.0'
    41 end
    42
    43 #Install/upgrade pip, setuptools and wheel
    44 bash 'Install-Setup-tools' do
    45 user 'root'
    46 cwd '/opt'
    47 code <<-EOH
    48 wget https://bootstrap.pypa.io/get-pip.py
    49 python3.6 get-pip.py
    50 EOH
    51 not_if { ::File::exists?("/opt/get-pip.py")}
    52 end

    Reply
  • 2017-06-01 at 19:08
    Permalink

    added a section for roots bash profile – since we manage that in chef

    1 # This installs python 3.6 in an alt location so as not to break the yum
    2
    3 # Install Compilers and related tools:
    4 execute ‘yum groupinstall -y “development tools”‘ do
    5 command ‘yum groupinstall -y “development tools –disableexcludes=all”‘
    6 end
    7
    8 # Install Libraries needed during compilation to enable all features of Python:
    9 %w{zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel expat-devel}.each do |pkg|
    10 package pkg do
    11 action :install
    12 end
    13 end
    14
    15 #create the install dir for python 3.6
    16 directory ‘/usr/local/python/lib’ do
    17 owner ‘root’
    18 group ‘root’
    19 mode ‘0755’
    20 recursive true
    21 action :create
    22 end
    23
    24 # Install Python 3.6.1 to /usr/local/python
    25 bash ‘install-python3.6.1’ do
    26 user ‘root’
    27 cwd ‘/opt’
    28 code <<-EOH
    29 wget http://python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
    30 tar xf Python-3.6.1.tar.xz
    31 cd Python-3.6.1
    32 ./configure –prefix=/usr/local/python –enable-shared LDFLAGS="-Wl,-rpath /usr/local/python/lib"
    33 make && make altinstall
    34 EOH
    35 not_if { ::File::exists?("/opt/Python-3.6.1.tar.xz")}
    36 end
    37
    38 #Bash_profile needs the new path – chef prefers to manage whole files
    39
    40 cookbook_file '/root/.bash_profile' do
    41 source 'root_bash_profile'
    42 action :create
    43 end
    44
    45 # strip symbols after install from the shared library to reduce the memory footprint
    46 execute 'strip-symbols' do
    47 command 'strip /usr/local/python/lib/libpython3.6m.so.1.0'
    48 end
    49
    50 #Install/upgrade pip, setuptools and wheel
    51 bash 'Install-Setup-tools' do
    52 user 'root'
    53 cwd '/opt'
    54 code <<-EOH
    55 wget https://bootstrap.pypa.io/get-pip.py
    56 python3.6 get-pip.py
    57 EOH
    58 not_if { ::File::exists?("/opt/get-pip.py")}
    59 end

    Reply
  • 2017-06-30 at 03:39
    Permalink

    I followed the instructions for Python 2.7 in CentOs 6.9 (Final)
    Dependencies and python 2.7 , make && make altinstall, and the files were created, but I cannot use it!?
    Error: python2.7:command not found
    —-cmd line—–
    [root@mail Python-2.7.13]# ls -l /usr/local/bin/py*
    -rwxr-xr-x 1 root root 84 Jun 29 21:20 /usr/local/bin/pydoc
    -rwxr-xr-x 1 root root 9784 Jun 29 21:27 /usr/local/bin/python2.7
    -rwxr-xr-x 1 root root 1687 Jun 29 21:28 /usr/local/bin/python2.7-config
    [root@mail Python-2.7.13]# python2.7 get-pip.py
    -bash: python2.7: command not found

    Reply
  • 2017-07-04 at 16:59
    Permalink

    Dear Daniel
    I installed Python 2.7.13 on CentOS 6.9 as following your guide above. but when I type the command “$ Python -V” it is still the previous version of 2.6 which does not support the program I want to install using “pip” command. how can I replace the old version of Python with the new installed?
    thanks

    Reply
    • 2017-07-04 at 16:06
      Permalink

      Please read the guide again. It clearly states that you cannot replace the default python version.

      Reply
  • Pingback: PyNSXv-Powerful tool for NSX Automation – Virtual Reality

  • 2017-07-12 at 21:00
    Permalink

    Thanks so much for posting this and keeping it updated! Love the detail. It’s helped me a ton!

    Reply
  • 2017-07-19 at 17:18
    Permalink

    I installed the version 2.7.5 but I don’t find the file “python2.7”. I don’t understand.
    Can you help me ?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *