简体   繁体   English

如何在 git bash 中更改我的 python 版本?

[英]How can I change my python version in git bash?

I been looking at fixes for this but im terrible at search.我一直在寻找解决方案,但我在搜索方面很糟糕。 I came across this fix我遇到了这个修复

didnt work没用

$ PATH=$PATH:/c/Python36/python
$ python --version
Python 2.7.13

I came across an alias fix turned out to be temporary so that didnt work我遇到了一个别名修复原来是临时的所以没有工作

I want basically every command i do like everything under Python36/Scripts like pip, pytest, etc to be from python36.我希望基本上每个命令我都喜欢 Python36/Scripts 下的所有命令,如 pip、pytest 等来自 python36。 But everything is going to python 2.7但一切都将走向 python 2.7

how do you change your python version?你如何改变你的 python 版本? I am trying to change my git bash python version from python 2.7.13 to 3.6.我正在尝试将我的 git bash python 版本从 Z23EEEB4347BDD26BFC6B7EE8A3B735.623 更改为I don't want to delete python 2.7 tho我不想删除 python 2.7 tho

Do this:做这个:

pkg install python2

And to use python2 do并使用 python2 做

python2 yourcode.py

And for python3 use而对于 python3 使用

python3 yourcode.py

To check Version if you check:如果您检查,请检查版本:

python - -version

It will give 3.9.2 for me and 3.6 for you but if you check它会给我 3.9.2 和 3.6 给你,但如果你检查

python2 - - version

It will give the result 2.7.18它将给出结果 2.7.18

Here is the proof:这是证明:证明

Check this in order to change the default python version without removing the package.选中此项以更改默认 python 版本而不删除 package。 https://unix.stackexchange.com/a/521060/214441 https://unix.stackexchange.com/a/521060/214441

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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