Python update (2.6-> 2.7)

Preface

Basically, the Python version upgrade of the system is NG.
If you need a different version, specify PATH each time.
However, I will leave the post in the hope that it will lead to the resolution when a similar error occurs.

(Thank you for your comment, knoguchi!)

Since subprocess.check_call is used, when updating python of the server that uses boto3, it was often more than expected, so it is a memorandum. Here's what I did: ・ Python update (2.6-> 2.7) ・ Reinstall boto3 because it can no longer be imported due to ↑ ・ Pip installation required for ↑

environment

It looks like the following

# python -V
Python 2.6.6
# uname -a
Linux hoge 2.6.32-573.12.1.el6.x86_64 #1 SMP Tue Dec 15 21:19:08 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

update

Update from source code.

Installation of required modules

Install the required modules in advance.

# yum install zlib-devel openssl-devel

If you don't do this, later pip installations will fail.

Error example)

# curl -kL https://bootstrap.pypa.io/get-pip.py | python
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1379k  100 1379k    0     0  11.7M      0 --:--:-- --:--:-- --:--:-- 24.0M
Traceback (most recent call last):
  File "<stdin>", line 17759, in <module>
  File "<stdin>", line 162, in main
  File "<stdin>", line 82, in bootstrap
zipimport.ZipImportError: can't decompress data; zlib not available
# curl -kL https://bootstrap.pypa.io/get-pip.py | python
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1379k  100 1379k    0     0  10.5M      0 --:--:-- --:--:-- --:--:-- 21.3M
Traceback (most recent call last):
  File "<stdin>", line 17759, in <module>
  File "<stdin>", line 162, in main
  File "<stdin>", line 82, in bootstrap
  File "/tmp/tmpd34pU2/pip.zip/pip/__init__.py", line 15, in <module>
  File "/tmp/tmpd34pU2/pip.zip/pip/vcs/subversion.py", line 9, in <module>
  File "/tmp/tmpd34pU2/pip.zip/pip/index.py", line 30, in <module>
  File "/tmp/tmpd34pU2/pip.zip/pip/wheel.py", line 35, in <module>
  File "/tmp/tmpd34pU2/pip.zip/pip/_vendor/distlib/scripts.py", line 14, in <module>
  File "/tmp/tmpd34pU2/pip.zip/pip/_vendor/distlib/compat.py", line 31, in <module>
ImportError: cannot import name HTTPSHandler

Download and install python2.7

# cd /usr/local/src
# curl -O https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz
# tar zxf Python-2.7.11.tgz
# cd Python-2.7.11
# ./configure
# make && make altinstall
# mv /usr/bin/python /usr/bin/python.26
# cp /usr/local/src/Python-2.7.11/python /usr/bin/python
# python -V
Python 2.7.11

Update complete!

Correspondence to harmful effects

Although I was able to update it above, I cleaned up everything.

yum recovery

It seems that yum is no longer available.

# yum list installed
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.7.11 (default, Jan 14 2016, 11:42:45) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)]

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

It corresponds by pointing the python used by yum to the old version.

vi /usr/bin/yum
× : #!/usr/bin/python
○ : #!/usr/bin/python.26

pip & boto3 installation

It seems that importing boto3 will fail. (Because it is not included for 2.7) Supported by reinstallation.

# curl -kL https://bootstrap.pypa.io/get-pip.py | python
# pip install boto3

Summary

It seems that the response is complete. Especially where yum can't be used, it's easy to overlook it if you don't know that yum is running on python.

You have to be careful about updates.

Recommended Posts

Python update (2.6-> 2.7)
python memorandum (sequential update)
Python
python chromedriver automatic update
How to update Python Tkinter to 8.6
Automatic update of Python module
[Python beginner] Update pip itself
kafka python
django update
Python basics ⑤
python + lottery 6
Python Summary
Built-in python
Python comprehension
Studying python
Python 2.7 Countdown
Python memorandum
Python FlowFishMaster
Python service
Bayes update
python tips
Python memo
Python comprehension
Replace dictionary value with Python> update ()
Python Singleton
Python basics ④
Python Memorandum 2
Python increment
atCoder 173 Python
[Python] function
Python installation
python tips
Installing Python 3.4.3.
Try python
Python memo
Python iterative
Python algorithm
Python2 + word2vec
[Python] Variables
Python functions
Python sys.intern ()
Python tutorial
Python decimals
python underscore
Python summary
Start python
[Python] Sort
Note: Python
Python basics ③
python log
Python basics
python memo
Python memorandum
Python # sort
ufo-> python
Python nslookup
python learning
Hannari Python 2020
[Rpmbuild] Python 3.7.3.
Prorate Python (1)
python memorandum