Python not available in Ubuntu xenial?

0

I have just provisioned a Xenial machine with vagrant (based on xenial64-20180228.1.0-virtualbox.box). In my host system I have python:

» lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.4 LTS
Release:        16.04
Codename:       xenial

» python --version
Python 2.7.12

But in the provisioned machine,

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.4 LTS
Release:        16.04
Codename:       xenial


$ python --version
The program 'python' can be found in the following packages:
 * python-minimal
 * python3
Ask your administrator to install one of them

$ python3 --version
Python 3.5.2

If I install python, it seems fine:

vagrant@ubuntu-xenial:~$ sudo apt-get install python
vagrant@ubuntu-xenial:~$ python --version
Python 2.7.12

Why is that? Is it normmal that python is not installed in a xenial image? Do I need to provision it manually then?

Note: the reason why I need python, and not simply python3, is that ansible explicitly looks for it when deploying to this machine:

/bin/sh: 1: /usr/bin/python: not found

dangonfast

Posted 2018-03-16T14:43:35.067

Reputation: 1 878

Answers

2

According to DistroWatch, Ubuntu Xenial ships with Python 3.5.1, which seems atypical when compared to other releases commonly being packaged with 2.X.X.

Refer to the comments on this question as to why Python 2 is called by the python command in Ubuntu. The top answer recommends using an alias to call Python 3 with python, as opposed to symlinking and breaking things that use on Python 2. Though I suppose that not having Python 2 installed would defeat the purpose of this precaution, and symlinking might be a viable solution.

Are you sure ansible isn't looking for Python 2? Here is a pretty recent link to their documentation on upcoming Python 3 support.

user881561

Posted 2018-03-16T14:43:35.067

Reputation:

ansible is looking for python, and expecting python2 I think. python3 is experimental afaik – dangonfast – 2018-03-19T05:34:48.570