我安裝的Ubuntu 默認的python是2.7.5
python -V
我參考網上照到的文章,如果需要默認python為 python3
python命令默認是 python 3
sudo cp /usr/bin/python /usr/bin/python_bak #備份默認的python文件
sudo rm /usr/bin/python #移除
sudo ln -s /usr/bin/python3 /usr/bin/python #使用軟鏈接,
python命令默認是 python 2
sudo cp /usr/bin/python /usr/bin/python_bak #備份默認的python文件
sudo rm /usr/bin/python #移除
sudo ln -s /usr/bin/python2 /usr/bin/python #使用軟鏈接,
wa@wa-VirtualBox:/usr/bin$ ls -l|grep python
-rwxr-xr-x 1 root root 1056 4月 16 2018 dh_python2
lrwxrwxrwx 1 root root 23 7月 10 00:51 pdb2.7 -> ../lib/python2.7/pdb.py
lrwxrwxrwx 1 root root 23 8月 21 01:12 pdb3.6 -> ../lib/python3.6/pdb.py
lrwxrwxrwx 1 root root 31 10月 1 18:09 py3versions -> ../share/python3/py3versions.py
lrwxrwxrwx 1 root root 9 4月 16 2018 python -> python2.7
lrwxrwxrwx 1 root root 9 4月 16 2018 python2 -> python2.7
-rwxr-xr-x 1 root root 3633480 7月 10 00:51 python2.7
lrwxrwxrwx 1 root root 9 10月 1 18:09 python3 -> python3.6
-rwxr-xr-x 2 root root 4526456 8月 21 01:12 python3.6
-rwxr-xr-x 2 root root 4526456 8月 21 01:12 python3.6m
lrwxrwxrwx 1 root root 10 10月 1 18:09 python3m -> python3.6m
lrwxrwxrwx 1 root root 29 4月 16 2018 pyversions -> ../share/python/pyversions.py
- pip
python2
sudo apt-get install python-pip
python3
sudo apt-get install python3-pip
因為我是使用py3,所以使用了這個命令,上面的命令也執行了......
pip update
pip install --upgrade pip