Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
470 views
in Technique[技术] by (71.8m points)

Python 2.7.5 and Python 3.6.5

I have installed Python 3.6.5 however when i type Python it shows Python 2.7.5. Id like to use Python 3.

[aravind@aravind05 Python-3.6.5]$ python3 --version
Python 3.6.5

[aravind@aravind05 Python-3.6.5]$ python
Python 2.7.5 (default, Apr 11 2018, 07:36:10)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

I want to use Python 3

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There are multiple ways to achieve this.

Assuming you are on some *NIX OS using a bourne-shell-like shell, you could define an alias alias python python3.

You could also place a symlink named 'python', pointing to python3 into a directory that is listed earlier in your PATH:

# on debian-like distributions, the following directories should be reasonable
ln -s ~/.local/bin/python "$(which python3)"
# place the following line into your .bashrc
export PATH="~/.local/bin/python:$PATH"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...