1

Ubuntu 18.04 comes with Python 3.6.9 by default. In order to run a project, I need to install Python 3.4.x. Is there a way to downgrade Python 3.6.9 to 3.4.x? Many thanks in advance!

Wendy
  • 69
  • 2
  • 5

3 Answers3

2

Python has this neat feature called virtual environments where you can setup different python versions for different projects. The documentation is pretty straightforward.

I would also recommend reading similar discussion that already exist.

As a final note I always name my virtual environment venv as its both simple and readable.

wjandrea
  • 28,235
  • 9
  • 60
  • 81
Taylor Cochran
  • 439
  • 4
  • 16
  • Thanks for your answer! But how can I create a virtual environment using Python 3.4.x if I have Python 3.6.9 installed on my Ubuntu? Thanks – Wendy Jun 09 '20 at 23:10
  • https://stackoverflow.com/questions/1534210/use-different-python-version-with-virtualenv – Taylor Cochran Jun 10 '20 at 18:51
1

I highly recommend using Pyenv to manage versions. You won't have to downgrade anything, just choose a different global python version.

liorr
  • 764
  • 5
  • 21
0

Ubuntu relies on Python 3.6. If you remove/change the system Python install, parts of the OS will break, like the terminal. Use a virtualenv instead.

First, you can use the deadsnakes PPA to install Python 3.4:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.4 python3.4-venv

Then set up the virtualenv. See the tutorial and venv documentation. The crucial command will be something like this:

python3.4 -m venv ...
wjandrea
  • 28,235
  • 9
  • 60
  • 81
  • Thanks for your answer! After I installed Python 3.4 using deadsankes PPA, I got an import error when trying to create a virtual environment using Python3.4. – Wendy Jun 10 '20 at 04:39
  • @Wendy Ah whoops, I hadn't noticed that `venv` isn't installed by default. Run `sudo apt-get install python3.4-venv` to install it. I updated the answer too. – wjandrea Jun 10 '20 at 14:38