如何在virtualen中运行visualstudio代码中的python程序

2024-10-01 15:32:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在virtualenv中运行python程序,但是如何使用visualstudio代码运行,尤其是单击run/debug时。(Ubuntu)

首先,我需要进入环境,这是我从terminalsource~/home/python/bin/activate运行的,然后是python测试.py其中python在virtualenv中指向python3.5

基本上我想用断点来调试。在


Tags: runpydebug程序homebin环境virtualenv
3条回答

请编辑启动.json添加配置

{
            "name": "Attach (Remote Debug)",
            "type": "python",
            "request": "attach",
            "localRoot": "${workspaceRoot}",
            "remoteRoot": "${workspaceRoot}",
            "port": 3000,
            "secret": "my_secret",
            "host": "localhost"
},

跟随链接:https://code.visualstudio.com/docs/editor/debugging

假设您使用的是用于visualstudio代码的donjayamanne.python插件,您可以在用户或工作区设置文件中进行设置(设置.json):

"python.pythonPath": "~/home/python/bin/python"

您可以使用“文件->首选项->设置”访问Visual Studio代码中的设置文件。在

下面介绍如何使用Pythonhttps://code.visualstudio.com/docs/languages/python运行visualstudio代码

编辑1:

Windows-Python虚拟环境和带有Visual Studio代码的PYTHONPATH:https://www.youtube.com/watch?v=AfvuK7US_9s

编辑2: Ubuntu-http://dacrook.com/setting-up-python-and-virtual-environments-in-visual-studio-code-on-ubuntu/

相关问题 更多 >

    热门问题