我目前在虚拟环境中运行Python程序,但是如何在Visual Studio Code中运行,特别是当单击运行/调试时(Ubuntu)。
首先,我需要进入环境,这是我从终端运行的命令source ~/home/python/bin/activate,然后运行Python测试.py,其中Python指向虚拟环境中的Python3.5。
基本上,我想通过使用断点进行调试。
我目前在虚拟环境中运行Python程序,但是如何在Visual Studio Code中运行,特别是当单击运行/调试时(Ubuntu)。
首先,我需要进入环境,这是我从终端运行的命令source ~/home/python/bin/activate,然后运行Python测试.py,其中Python指向虚拟环境中的Python3.5。
基本上,我想通过使用断点进行调试。
请编辑launch.json并添加配置
{
"name": "Attach (Remote Debug)",
"type": "python",
"request": "attach",
"localRoot": "${workspaceRoot}",
"remoteRoot": "${workspaceRoot}",
"port": 3000,
"secret": "my_secret",
"host": "localhost"
},
这是关于使用Visual Studio Code进行调试的文档。"python.pythonPath": "~/home/python/bin/python"
您可以通过选择“文件”->“首选项”->“设置”来访问Visual Studio Code中的设置文件。