0

I am trying to install 2 python versions:

1) 2.7.14

2) 3.7.2-1

I created them by using make commands:

wget https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz

tar -xvf Python-2.7.14.tgz

cd Python-2.7.14

./configure --without-ensurepip --enable-optimizations

make

checkinstall -y

When I am unpacking one of them it overrides the second installed:

dpkg -i python_2.7.14-1_amd64.deb

dpkg: warning: downgrading python from 3.7.2-1 to 2.7.14-1

(Reading database ... 35940 files and directories currently installed.)

Preparing to unpack python_2.7.14-1_amd64.deb ...

Unpacking python (2.7.14-1) over (3.7.2-1) ...

Setting up python (2.7.14-1) ...

How can I have them both running on my ubuntu?

**** NOTE I DON'T WANT TO USE VIRTUAL ENVIRONMENT ****

  • Already answered many times https://stackoverflow.com/questions/2547554/multiple-python-versions-on-the-same-machine – riverfall Mar 12 '19 at 12:11

2 Answers2

0

Python is already installed on your machine... If you would run a different version, you'd better configure a virtual environment

Glori P.
  • 466
  • 1
  • 4
  • 14
  • But Ubuntu can have 2 versions, as far as I know. I have a machine with both 2.7 and 3.5 running without virtual environment. – Danny Kaganovitch Mar 12 '19 at 12:13
  • yeas you can have a version of python3 and one of python 2. On Ubuntu 18 python 2 is not installed by default. please check https://linuxconfig.org/install-python-2-on-ubuntu-18-04-bionic-beaver-linux – Glori P. Mar 12 '19 at 12:15
  • have you tried `sudo apt install python-minimal`? with this I have installed `Python 2.7.15` but you would like to have 2.7.14, right? – Glori P. Mar 12 '19 at 14:52
  • 1
    BTW I do not recommend you to install another python version than the one you have by default. Ubuntu 18 comes with a particular version of python 3 and the entire system has this "dependency". the story changes using a virtual enviroment – Glori P. Mar 12 '19 at 14:57
0

First of all, uninstall any other package higher than 2.7.

Option 1:

You may use the source code python and "make altinstall"

Docs: https://docs.python.org/3/using/unix.html#building-python

Option 2:

Using apt-get I could install/update versions 2.7.15 and 3.7.1-1 using docker environment with this Dockerfile:

FROM ubuntu:18.04

USER root

WORKDIR /app

RUN apt-get update && apt-get install python=2.7.15~rc1-1 python3.7=3.7.1-1~18.04 -y

This means, if you use this code:

apt-get update && apt-get install python python3.7 -y

It will probably work.

Fábio Correia
  • 595
  • 7
  • 16
  • Didn't help, tried to install: make, make altinstall, checkinstall -y and Python3 overrided the Python2 – Danny Kaganovitch Mar 12 '19 at 13:30
  • make install just changes the executable, if python3 with make install you should use "python3" as executable, and python 2 will be only "python". Further installations of minor versions like 3.6.2, will be "Python3.6" and on. – Fábio Correia Mar 12 '19 at 14:13
  • Within the Ubuntu usually the 2.7 is already installed and any other version you should install (if you want both working) from source code and not deb packages. My last guess is that you should make the one you already have intact, then install the next one from source code and not use .deb packages. I will test with Dockerfile to check if this scenario will work. – Fábio Correia Mar 12 '19 at 14:46