简体   繁体   中英

Why can't I run python in git bash and visual studio code?

I'm having a hard time understanding and running a terminal. I downloaded python 3.11 from the official website and installed it. I also checked the box at the beginning of the installment to add python to PATH. But when I try to run it on git bash it just gives me an empty line. On Visual code, It takes to download python through the Microsoft store. But is it makes sense to download it twice, through the website and through the store...?

git bash picture:
git bash 图片

visual code terminal picture:
可视码终端图片

On Visual code, It takes to download python through the Microsoft store

If my understanding is correct, Windows comes with dummy python executables python.exe and python3.exe that take you to the microsoft store to install it- after which it is a real python executable instead of a dummy one. If you run where python , you'll get a list of all the python executables that are found via the PATH variable in the order that they are found in the PATH , where one of them will be the Windows one (instead of the one you installed from the Python website). Likely, the one you'll see listed first will be C:\Users\you\AppDate\Local\Microsoft\WindowsApps\python.exe .

What you probably need to do is update the order of entries in your PATH environment variable so that the directory containing the one you installed from the Python website is earlier in the PATH environment variable than the directory of the out-of-box Windows one.

Note: As indicated in this question: why must python executable path be added to system PATH environment variables for python command to work in visual studio code , you might need to add the directory containing your from-website Python to the system PATH environment variable (before/above the path to the directory of the system one) (as opposed to the user PATH environment variable).

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-2025 STACKOOM.COM