简体   繁体   中英

Not being able to change version of python from 2.7-3.6

I am trying python --version in my windows subsystem for linux terminal and it is showing me 2.7.15 whereas I do not have 2.7 in my system. I have python 3.6 set in my environment variable, and that is the python interpreter I have used till date. Suddenly after restarting my system I could see that version is 2.7. How do I change the version of python and set it to my original interpreter? I have tried sudo apt update && upgrade and then sudo apt install python3 python3-pip ipython3. Did not help. Please help.

Try python3 --version or python3.6 --version

Run these 2 commands

pip install --upgrade virtualenv

virtualenv -p python3 envname

You can use python3 as python3 or python3.6

If you still want to use python3 with the python command, edit your ~/.bash_profile file and add line alias python='python3' and restart terminal

you can try using alternatives install python 3.6 and try # alternatives --config python and choose the alternative version

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM