简体   繁体   中英

I can't run python on visual studio code

Image case for the problem

截屏

I was following the Visual Studio Code tutorial for python here https://code.visualstudio.com/docs/python/python-tutorial

I downloaded Python, installed the python extension in Visual Studio Code and set the python interpreter to python3.8. I also checked the workspace settings to see if it had given the correct path. Then, I wrote a simple hello world program but this is the error it is giving me.

This is the python path it has in the settings.

C:\Users\Dell\AppData\Local\Microsoft\WindowsApps\python.exe

Program:

print("Hello World")

Error:

C:/Users/Dell/AppData/Local/Microsoft/WindowsApps/python.exe c:/Users/Dell/hello/hello.py -bash: C:/Users/Dell/AppData/Local/Microsoft/WindowsApps/python.exe: No such file or directory

I tried uninstalling and installing all the extensions again but it didn't work. I also uninstalled and installed all python related things on my computer. That didn't work either. What should I do?

reinstall python and this time, add python to the PATH (there is an option on the installation screen. Check it as it isn't checked by default). Then try running vs

Your environment path is not configured properly reinstalling python will fix this make sure you install python from actual application and not from vscode.other solution is that you can set the enviornment path manually just go to the environment variables> under user variable set the path to your python.exe the above mentioned location seems unlikely it should contain main python folder such as Python37/....

I will suggest you follow the link mentioned in this blog post to have python installed and working with Visual Studio Code. https://techdirectarchive.com/2023/01/17/getting-started-with-python-automation-in-windows-with-visual-studio-code/

Microsoft recommends installing python from the Microsoft Store. since installing from the Microsoft Store uses the basic Python3 interpreter, and handles the set-up of your PATH settings for the current user (avoiding the need for admin access), in addition to providing automatic updates.

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