Hadoop(cloudera)

`Not able to upgrade python on cloudera as it shows the error whenever i run the below command:

sudo yum install python27
error: No package python27 available
sudo yum install python36u
No package python36u available

i also run yum install mrjob but still not able to upgrade my python in cloudera`

Hi @vikram1

Kindly run this python code:

import sys
print("Python version")
print (sys.version)
print("Version info.")
print (sys.version_info)

and post back the results

1 Like
#! /usr/bin/python
import sys
print("Python Version")
print(sys.version)
print("Version info.")
print(sys.version_info)

OutPut of above Code is:

Python Version
2.6.6 (r266:84292, Jun 20 2019, 14:14:55) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)]
Version info.
(2, 6, 6, 'final', 0)

Did you try not using yum?

For example only:

# python 2.7.14:
wget http://python.org/ftp/python/2.7.14/Python-2.7.14.tar.xz
tar xf Python-2.7.14.tar.xz
cd Python-2.7.14
./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
make && make altinstall
 
# Python 3.6.3:
wget http://python.org/ftp/python/3.6.3/Python-3.6.3.tar.xz
tar xf Python-3.6.3.tar.xz
cd Python-3.6.3
./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
make && make altinstall
1 Like

Try

yum search python
1 Like

Commands work successfully but still my python is not upgraded showing me the same version 2.6

wget http://python.org/ftp/python/2.7.14/Python-2.7.14.tar.xz
tar xf Python-2.7.14.tar.xz
cd Python-2.7.14
./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
make && make altinstall

Python Version
2.6.6 (r266:84292, Jun 20 2019, 14:14:55) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)]
Version info.
(2, 6, 6, 'final', 0)

In general, @vikram1

You need to either change or set a python alias to the version you want, for example:

alias python='/usr/local/bin/python3'

Or you can set up a symbolic link as required.

Did you pay attention during your install to see where your version of python 2.7.14 was installed?

For example, on this linux system:

linux:/usr/local/bin# cd /usr/bin
linux:/usr/bin# ls -l python*
lrwxrwxrwx 1 root root       9 Apr 16  2018 python -> python2.7
lrwxrwxrwx 1 root root       9 Apr 16  2018 python2 -> python2.7
-rwxr-xr-x 1 root root 3670448 Nov 12  2018 python2.7
lrwxrwxrwx 1 root root      33 Nov 12  2018 python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root      16 Apr 16  2018 python2-config -> python2.7-config
-rwxr-xr-x 1 root root     399 Nov 15  2017 python2-jsonschema
-rwxr-xr-x 1 root root     154 Nov 11  2017 python2-pbr
-rwxr-xr-x 1 root root    5901 Jul 27  2017 python2-wsdump
lrwxrwxrwx 1 root root       9 Jun 21  2018 python3 -> python3.6
-rwxr-xr-x 2 root root 4576440 Apr  1  2018 python3.6
-rwxr-xr-x 2 root root 4576440 Apr  1  2018 python3.6m
-rwxr-xr-x 1 root root     384 Feb  5  2018 python3-futurize
lrwxrwxrwx 1 root root      10 Jun 21  2018 python3m -> python3.6m
-rwxr-xr-x 1 root root     388 Feb  5  2018 python3-pasteurize
-rwxr-xr-x 1 root root     152 Nov 11  2017 python3-pbr
lrwxrwxrwx 1 root root      16 Apr 16  2018 python-config -> python2.7-config

@vikram1, you can set the version with either an alias or a symbolic link, or you can call your version directly for example:

linux:/usr/bin# python2.7 --version
Python 2.7.15rc1
linux:/usr/bin# python3.6m --version
Python 3.6.5

See also, for example:

See also, for example:

There are myriad tutorials on the net on how to change between python versions.

1 Like