vscode设置pycharm中的项目路径和debug方法

  1. 命令行运行:
    export PYTHONPATH=:pwd:/home/bennie/bennie/bennie_project/AI_Lab
    python main.py
    当关闭此命令行时,临时路径会清除,可以将上述export的整条语句,加入~/.bashrc中
    该命令中,以:分隔两个不同的路径

debug

vsocde的debug需要设置launch.json,字段中env是重要的

json 复制代码
{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Build_Seg_Model",
            "type": "python",
            "request": "launch",
            "program": "/home/T/T/T/AI_Lab/seg_module/Segment_Lab/BuildSegModel.py",
            "console": "integratedTerminal",
            "justMyCode": false,
            "env": {
                "PYTHONPATH": "${workspaceRoot}"
            },
        }
    ]
}

当设置为这样的pythonpath后,所有的导入都可以从项目目录开始import

相关推荐
我待_JAVA_如初恋8 小时前
idea创建MavenJavaWeb项目以后,包结构缺java
java·ide·intellij-idea
言之。11 小时前
Claude Code IDE 集成工作原理详解
ide·人工智能
悠悠子衿1213812 小时前
Claude+VSCODE配置git导致频繁弹出git bash 的CMO窗口解决方法
ide·git·vscode
大志哥12312 小时前
IntelliJ IDEA父子工程中导入公网远程备份项目到新目录
java·ide·intellij-idea
梁萌13 小时前
idea使用AI插件(CodeGeeX)
java·ide·ai·intellij-idea·插件·codegeex
wqfhenanxc14 小时前
vscode/cursor 远程Linux基础命令
linux·ide·vscode
我命由我1234514 小时前
Python 开发问题:No Python interpreter configured for the project
开发语言·后端·python·学习·pycharm·学习方法·python3.11
Lv117700815 小时前
Visual Studio中的常量和只读变量
ide·笔记·c#·visual studio
Balding Curry15 小时前
vscode快速添加插件的3种方式
ide·vscode·编辑器
yyovoll15 小时前
循环知识点介绍 -蓝桥杯
jvm·ide·java-ee