简体   繁体   English

我无法在 Visual Studio 代码上运行 python

[英]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我在这里关注 python 的 Visual Studio Code 教程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.我下载了 Python,在 Visual Studio Code 中安装了 python 扩展,并将 python 解释器设置为 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.然后,我写了一个简单的 hello world 程序,但这是它给我的错误。

This is the python path it has in the settings.这是它在设置中的 python 路径。

C:\Users\Dell\AppData\Local\Microsoft\WindowsApps\python.exe 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 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: 没有那个文件或目录

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.我也在我的电脑上卸载并安装了所有python相关的东西。 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).重新安装 python ,这次,将 python 添加到 PATH (安装屏幕上有一个选项。选中它,因为它默认没有选中)。 Then try running vs然后尝试运行 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/....您的环境路径未正确配置重新安装 python 将解决此问题确保您从实际应用程序而不是从 vscode 安装 python。其他解决方案是您可以手动设置环境路径,只需在用户变量下将 Z34D1F91FB2E514B8576FAB1A75A89AZ 设置为环境变量>您的 python.exe 上述位置似乎不太可能包含主 python 文件夹,例如 Python37/....

I will suggest you follow the link mentioned in this blog post to have python installed and working with Visual Studio Code.我建议您点击这篇博文中提到的链接来安装 python 并使用 Visual Studio Code。 https://techdirectarchive.com/2023/01/17/getting-started-with-python-automation-in-windows-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. Microsoft 建议从 Microsoft Store 安装 python。 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.因为从 Microsoft Store 安装使用基本的 Python3 解释器,并为当前用户处理 PATH 设置的设置(避免需要管理员访问),此外还提供自动更新。

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

相关问题 Visual Studio Code 无法正常运行 Python - Visual Studio Code can't run Python propertly 我无法通过Visual Studio在python中运行Sigmoid函数代码 - I can't run my sigmoid function code in python by visual studio 为什么我不能在git bash和visual studio代码中运行python? - Why can't I run python in git bash and visual studio code? 我可以在没有所有开销的情况下在 Visual Studio Code 中运行 python 吗? - Can I run python in Visual Studio Code without all the overhead? 无法在Visual Studio中运行Python脚本 - Can't run Python script in Visual Studio Visual Studio Code 不会运行我的 python 代码 - Visual Studio Code won't run my python code 为什么我的代码不能在 Visual Studio Code 中运行? - Why can't my code run in Visual Studio Code? Python 在 Visual Studio Code 上无法正常运行 - Python doesn't run properly on Visual Studio Code 无法使用 Jupyter 在 Visual Studio Code 中运行 Python 代码 - “无法从‘Python 3.6.8 64 位’启动 Jupyter 内核” - Can't run Python code in Visual Studio Code with Jupyter - "Jupyter kernel cannot be started from 'Python 3.6.8 64-bit" 我无法在Visual Studio Code上格式化Python文件:“没有安装用于'python'文件的文档格式化程序。” - I can't format Python file on Visual Studio Code: “There is no document formatter for 'python'-files installed.”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM