Reputation: 2210
Is there a way to make python3.5 as the default python in AWS. every time i try the next time i connect python2.7 is the default one and pip 6 is the last version, knowing that I did updated it some minutes before. here is the method i followed : amazon_link
here is another link of amazon telling the versions, actually they are at 3.5 another_link
Thank you in advance, :) best wishes
Upvotes: 9
Views: 33735
Reputation: 65
I used alias and it works for me. (AMI2 AWS)
alias python=python3
Add this command in .bashrc
file and then reboot the server
python --version
It will show python version 3
Upvotes: 3
Reputation: 297
Because AL2 is picky, unfortunately NONE of these answers is exactly correct. Here's what worked for me just now (as root)-
alternatives --install /usr/bin/python python /usr/bin/python2.7 1
alternatives --install /usr/bin/python python /usr/bin/python3.7 2
3.7 SHOULD be the default now, and you can test with python --version
.
To change the default at any time:
update-alternatives --config python
The menu system will prompt you through the change.
Upvotes: 0
Reputation: 1476
To change Python Version 3.x
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.x 1
*** Because sometimes priority is required use, you just add '1' at end of command line.**
To check update
sudo update-alternatives --list | grep python
Reset Python old version'
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
Just close terminal and restart.
Python -V
3.x
Good luck
Upvotes: 1
Reputation: 708
By default, the awscli-bundle install script runs under the system default version of Python. To answer your question you will need to know the path of Python version to use. Then run:
$ sudo /path/to/python/version awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
In my case I would run:
$ sudo /usr/local/bin/python3.7 awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
Upvotes: 1
Reputation: 11
do above: alias python=python36
in ~.bashrc file (Use emacs, vim, your favorite editor - emacs ~.bashrc
) then save file.
then in command line terminal type: source ~/.bashrc
(for changes to take effect)
Upvotes: 0
Reputation: 862
alternatives --set python /usr/bin/python3.5
and then back if you want to
alternatives --set python /usr/bin/python2.7
If you want to see what it currently points to
alternatives --display python
This is a system-wide setting not just for the current user. The system settings are stored in /etc/alternatives
Upvotes: 30
Reputation: 873
A simple safe way would be to use an alias
. Place this into ~/.bashrc
or ~/.bash_aliases
file:
alias python=python3
Example
$ python --version
Python 2.7.6
$ python3 --version
Python 3.4.3
$ alias python=python3
$ python --version
Python 3.4.3
Upvotes: 13