Ankita
Ankita

Reputation: 79

How Can I upgrade my python3 version from 3.5.2 to 3.7 in AWS EC2 ubuntu instance?

How Can I upgrade my python3 version from 3.5.2 to 3.7 in AWS EC2 ubuntu instance?

i am getting ImportError: No module named 'secrets' error while trying to runserver using command python3 manage.py runserver. I read somewhere that secrets are not supported in python3 version 3.5, and it works for only higher versions. My python version is 3.5.2. I want to upgrade the version.

I tried sudo apt-get install python3.7, but its not working:

Building dependency tree Reading state information... Done 
E: Unable to locate package python3.7 
E: Couldn't find any package by glob 'python3.7'
E: Couldn't find any package by regex 'python3.7'

Then I tried sudo update-alternatives --config python3, this is also not working

update-alternatives: error: no alternatives for python3

Upvotes: 0

Views: 3637

Answers (2)

Umer Rana
Umer Rana

Reputation: 178

Try this:

sudo apt-get update
sudo apt-get install build-essential libpq-dev libssl-dev openssl libffi-dev zlib1g-dev
sudo apt-get install python3-pip python3.7-dev
sudo apt-get install python3.7

In case you don't have the repository and so it fires a not-found package you first have to install this:

sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update

Upvotes: 1

Avinash Dalvi
Avinash Dalvi

Reputation: 9321

Try this :

first do this:

sudo apt update
sudo apt install software-properties-common

Then


sudo add-apt-repository ppa:deadsnakes/ppa 
sudo apt-get install python3.7

reference : https://linuxize.com/post/how-to-install-python-3-8-on-ubuntu-18-04/

Upvotes: 1

Related Questions