Update python on linux 2.7 to 3.5

前端 未结 4 903
一个人的身影
一个人的身影 2021-01-12 07:03

So I updated python using these instructions:

sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev l         


        
4条回答
  •  悲哀的现实
    2021-01-12 07:20

    You still have Python 2 installed, and the python command is still set up to invoke that version by default. Try running your scripts like this:

    python3 yourscriptname.py
    

    In /usr/bin/, "python" is actually a symlink to python2.7. If you'd rather not have to type the 3 at the end whenever you use python, change that symlink to point to python3 instead. Then python will run Python 3.5 and you can use python2.7 or just python2 to run Python 2.7 scripts.

    EDIT: Alternatively, you could put alias python=python3 in your ~/.bashrc file to do the same thing, but without needing root access and for your user account only.

提交回复
热议问题