程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Change the default Python version of Linux

編輯:Python

Method 1

When you install Debian Linux when , The installation process may provide you with multiple available Python edition , So there will be multiple Python Executable binaries for . You can use ls Command to see what is in your system Python Binary files of are available for use .

ls /usr/bin/python*

/usr/bin/python /usr/bin/python2 /usr/bin/python2.7 /usr/bin/python3 /usr/bin/python3.4 /usr/bin/python3.4m /usr/bin/python3m
Copy
Execute the following command to view the default Python Version information :

python --version

Python 2.7.8
Copy
1、 User based modification Python edition :

Want to modify... For a specific user Python edition , Just in it home Create one in the directory alias( Alias ) that will do . Open the user's ~/.bashrc file , Add new alias information to modify the default alias Python edition .

vim ~/.bashrc
alias python='/usr/bin/python3.4'

Copy
Once the above operations are completed , Log in again or reload .bashrc file , Make the operation effective .

 . ~/.bashrc

Copy
Check the current Python edition .

python --version

Python 3.4.2

Method 2

which python3

/data/anaconda3/bin/python3

cd /usr/bin
ls -l | grep python
sudo rm -rf python
sudo ln -s /usr/bin/python3 /usr/bin/python
sudo ln -s /usr/bin/python2 /usr/bin/python

Restart the client to take effect


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved