Skip to main content
 首页 » 编程设计

python之运行 Python 文件时 VS Code 错误 22

2024年11月24日8bluestorm

我正在尝试在 Visual Studio Code 中运行一个简单的 python 代码。我的 launch.json 看起来像这样:

{ 
    // Use IntelliSense to learn about possible attributes. 
    // Hover to view descriptions of existing attributes. 
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 
    "version": "0.2.0", 
    "configurations": [ 
        { 
            "name": "Python : Fichier actuel", 
            "type": "python", 
            "request": "launch", 
            "program": "${file}", 
            "console": "integratedTerminal" 
        } 
    ] 
} 

这是完整的错误:

D:\Me\Documents\MEGA\IPSA\Aéro 3\Optimisation différentiable\TP-Projet>cd "d:\Me\Documents\MEGA\IPSA\Aéro 3\Optimisation différentiable\TP-Projet" && cmd /C "set "PYTHONIOENCODING=UTF-8" && set "PYTHONUNBUFFERED=1" && "C:\Users\My Username\AppData\Local\Programs\Python\Python37\python.exe" """c:/Users/My Username/.vscode/extensions/ms-python.python-2019.5.17517/pythonFiles/ptvsd_launcher.py""" --default --client --host localhost --port 9975 "d:\Me\Documents\MEGA\IPSA\Aéro 3\Optimisation différentiable\TP-Projet\projet.py" " 
C:\Users\My Username\AppData\Local\Programs\Python\Python37\python.exe: can't open file '"c:/Users/My Username/.vscode/extensions/ms-python.python-2019.5.17517/pythonFiles/ptvsd_launcher.py"': [Errno 22] Invalid argument 

调试器没有启动,并且出现一条错误消息告诉我调试器没有响应。我做错了什么吗?这只是 VS Code 处理文件路径的方式中的错误吗?

请您参考如下方法:

我的用户名中也有空格,现在你只需要运行,尝试将你的 python 扩展回滚到 2019.4.12954 以避免。它看起来像是 2019.5.17059 的错误。