Monday, 5 December 2016

Installing Python on Linux without disrupting existing one

Python is important package that comes installed on Linux systems. Corrupting the pre-installed version makes many of the packages non-usable. I could not yum after the pre-installed version of Python was corrupt.

Here is how you can install a version of Python on Linux operating system, keeping the pre-installed one safe. Here, we use CentOS 6.4 version, which is a pretty old release.

Issues solved by this document

pip is an important module you need while working on Python. Following are the errors I have faced while trying to install pip module and this document helps you in solving them too:
  • zipimport.ZipImportError: can't decompress data; zlib not available

    [root@localhost tmp]# python2.7 
    Traceback (most recent call last):
      File "", line 20061, in 
      File "", line 194, in main
      File "", line 82, in bootstrap
        import pip
    zipimport.ZipImportError: can't decompress 
    data; zlib not available

  • There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available.

    [root@localhost tmp]# python2.7 
    pip is configured with locations that require TLS/SSL, 
    however the ssl module in Python is not available.
    Collecting pip
      Could not fetch URL
    ip/: There was a problem confirming the ssl certificat
    e: Can't connect to HTTPS URL because the SSL module i
    s not available. - skipping
      Could not find a version that satisfies the requirem
    ent pip (from versions: )
    No matching distribution found for pip
    [root@localhost tmp]#

Verify the current version

You may use python --version command on the terminal to find the current version.

Installing a different version

  1. You may download a version you would need to install from Python Download. By default, Python comes as tarball for Linux.
  2. Once you have the tarball downloaded, copy it to a location where we extract and do the installation. Here, I copied the 2.7.12 version to /tmp. Use the version which is available for your platform and remember to use the commands accordingly.
  3. Extract tarball and change directory to the extracted folder.
    tar xvf Python-2.7.12.tar.xz
    cd Python-2.7.12
  4. Install required Linux packages. gcc is a utility for compiling and installing Python from source, zlib-devel and openssl-devel are required to avoid errors while installing pip module at a later stage. You would need to be root or a sudoer to install these packages:
    yum install gcc
    yum install zlib-devel
    yum install openssl-devel
  5. Run configure with option to export shared libraries. This is necessary if you would need to use pyinstaller module.
    ./configure --enable-shared
  6. Generate the build:
  7. Install Python without replacing the existing version. Using altinstall option will help you to use the new installation with version suffix during execution. e.g. python2.7 --version:
    make altinstall
  8. Make a link to Python library path:
  • On 32 bit OS
    ln -s /usr/local/lib/ /usr/lib/
  • On 64 bit OS
     ln -s /usr/local/lib/ /usr/lib64/

 Installing pip module

Here is how you may get pip for the Python version you have just installed:
  1. Running is a better way to install pip. file is available at pip module listing.
  2. Run with the version of Python you have installed. For example:
    This installs a pip utility which you can use with suffix. e.g. pip2.7 install pyinstaller 


  1. Thank you very much James. I got the same problem and your post really helped!

    1. Hi, glad that it helped! Cheers!

    2. Great Article android based projects

      Java Training in Chennai

      Project Center in Chennai

      Java Training in Chennai

      projects for cse

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

  2. Thank you! This is awesome. So simple, yet impossible to get a straight procedure like this anywhere else

  3. This is great and works really well. However if this is meant to install python3.6, the correction to step 8 should read
    ln -s /usr/local/lib/ /usr/lib64/

    Thanks James!

  4. Thanks for sharing. This helped.

  5. Thank you so much! I follow this for python 3.6 and it worked perfectly.

  6. Does your blog have a contact page? I’m having problems locating it but, I’d like to shoot you an email. I’ve got some recommendations for your blog you might be interested in hearing.
    AWS Training in Chennai |Best Amazon Web Services Training in Chennai
    Best AWS Amazon Web Services Training in Chennai | AWS Training in Chennai cost
    No.1 AWS Training in Chennai | Amazon Web Services Training Institute in Chennai

  7. Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article. thank you for sharing such a great blog with us.
    microsoft azure training in bangalore
    rpa training in bangalore
    rpa training in pune
    best rpa training in bangalore

  8. This looks absolutely perfect. All these tiny details are made with lot of background knowledge. I like it a lot. 
    Best Devops training in sholinganallur
    Devops training in velachery
    Devops training in annanagar
    Devops training in tambaram

  9. My developer is trying to convince me to move to .net from PHP. I have always disliked the idea because of the expenses. But he’s trying none the less. I’ve been using Movable-type on several websites for about a year and am anxious about switching to another platform. I have heard great things about Is there a way I can transfer all my Word Press posts into it? Any help would be appreciated.
    python training Course in chennai
    python training in Bangalore
    Python training institute in bangalore

  10. The post is written in very a good manner and it entails many useful information for me. I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept.

    DevOps Training in Bangalore

    DevOps Training in Bangalore

    DevOps Training in Bangalore

    DevOps Training in Marathahalli

    DevOps Training in Pune

    DevOps Online Training-gangboard

  11. Thanks for valuable information. I found it very useful.

  12. Home Mart is a site about Home Improvement, Furniture, Home Appliances and many more.
    Check out the best
    furniture sale
    Dog Cages
    bedroom furniture nz

  13. For Devops Training in Bangalore Visit: Devops Training in Bangalore

  14. Thanks for sharing is so amazing and helpful to us.
    Buy Hydrocodone online


  15. Best Article buy Pain Pills online Excellent post. I appreciate this site. Stick with it! Because the admin of this web page is working, no doubt very quickly it will be well-known, due to its quality contents.This website was how do you say it? Relevant!! Finally, I’ve found something that helped me.
    Best Article buy Roxicodone online Excellent post
    buy Xanax online
    buy Oxycodone online

    Best Article buy Pain Medications online Excellent post. I appreciate this site. Stick with it! Because the admin of this web page is working, no doubt very quickly it will be well-known, due to its quality contents.This website was how do you say it? Relevant!! Finally, I’ve found something that helped me.

    buy Research Chemicals online

    buy Roxicodone online

    buy Cbd Isolate online

  16. Marijuana—also called weed, herb, pot, grass, bud, ganja, Mary Jane, and a vast number of other slang terms—is a greenish-gray mixture of the dried flowers of Cannabis sativa.

    The main active chemical in marijuana is THC (delta-9-tetrahydrocannabinol), the psychoactive ingredient. The highest concentrations of THC are found in the dried flowers, or buds. When marijuana smoke is inhaled, THC rapidly passes from the lungs into the bloodstream and is carried to the brain and other organs throughout the body. THC from the marijuana acts on specific receptors in the brain, called cannabinoid receptors, starting off a chain of cellular reactions that finally lead to the euphoria, or "high" that users experience. Feeling of a relaxed state, euphoria, and an enhanced sensory perception may occur. With higher THC levels in those who are not used to the effects, some people may feel anxious, paranoid, or have a panic attack.
    Cannabis plant used for medical or recreational purposes. The main psychoactive part of cannabis is tetrahydrocannabinol, one of the 483 known compounds in the plant, including at least 65 other cannabinoids. 
    buy real weed online
    how to buy weed online
    buy legal weed online
    buy recreational weed online
    buy weed edibles online
    can i buy weed online
    buy medical weed online
    buy weed online canada
    buying weed online reviews
    buy weed online legit
    buy weed online without medical card
    buy weed seeds online canada
    order marijuana online
    order marijuana seeds online
    how to order marijuana online
    order marijuana online without a medical card
    can you order medical marijuana online
    order marijuana online

  17. very nice blogs!!! i have to learning for lot of information for this sites...Sharing for wonderful information.Thanks for sharing this valuable information to our vision.

    AWS training in Chennai

    AWS Online Training in Chennai

    AWS training in Bangalore

    AWS training in Hyderabad

    AWS training in Coimbatore

    AWS training

    AWS online training

  18. Good Post! , it was so good to read and useful to improve my knowledge as an updated one, keep blogging.After seeing your article I want to say that also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts likethis.

  19. Thanks for shared that blog with us. If anyone here searching Python Exception Class then visit Coding Dolphin.

  20. Thanks for sharing this amazing article. This was truly informative.

    Buy Custom Website

  21. I'm truly grateful to you for offering Such sort of instructive articles to us.
    Really helpful.
    buy logo design

  22. Usually, I never comment on blogs but your article is so convincing that I never stop myself to say something about it. You’re doing a great job Man, Keep it up.
    Custom Logo Design

  23. Thanks for Sharing a Very Informative Post & I read Your Article & I must say that is very helpful post for us.
    Data Science Course in Pune

  24. Your article is very informative and has a lot of information. I really like your effort, keep posting.
    Moreover, if you are looking for professional law dissertation proposal services, check this.

  25. Such an very helpful and amazing post thanks for sharing with us.
    Buy Logo Design

  26. Fantastic blog! Thanks for sharing a very interesting post, I appreciate to blogger for an amazing post.
    Data Science Course in Pune
    Python Classes in Pune

  27. It is surely an amazing post, thank you so much for the share. Also, visit our website if you are looking to buy amazing products in Pakistan:


  28. I feel good about your share.
    It's very helpful for me and I am so happy to see your blog.
    Thank you for sharing it with us.
    Law essay help


  29. It’s great to come across a blog every once in a while that isn’t the same out of date rehashed material. Fantastic read. Best cheat sheet service provider.


  30. Hey what a brilliant post I have come across and believe me I have been searching out for this similar kind of post for past a week and hardly came across this. Thank you very much and will look for more postings from youftp ports