dlliang14 2023-04-07 10:40 采纳率: 75%
浏览 15
已结题

vscode import失败

问题遇到的现象和发生背景

vscode 使用python进行绝对导入 失败,尝试了好久,不知道哪里有问题。明明cmd目前目录在根目录,但是执行的时候还是找不到根目录

img

操作环境、软件版本等信息

下面是vscode我目前的setting.json

{
  "editor.formatOnType": true,
  "editor.formatOnSave": true,
  "files.autoSave": "afterDelay",
  "workbench.editorAssociations": {
    "*.ipynb": "jupyter-notebook"
  },
  "notebook.cellToolbarLocation": {
    "default": "right",
    "jupyter-notebook": "left"
  },
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "[python]": {
    "editor.wordBasedSuggestions": false
  },
  "python.autoComplete.extraPaths": [],
  "python.analysis.extraPaths": [],
  "security.workspace.trust.untrustedFiles": "open",
  "workbench.startupEditor": "none",
  "[jsonc]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  // "terminal.integrated.shell.windows":"C:\\Windows\\System32\\cmd.exe",
  // "terminal.integrated.shell.windows":"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
  "terminal.integrated.profiles.windows": {
    "Git-Bash": {
      "path": "C:\\program files\\Git\\bin\\bash.exe",
      "args": [],
      "icon": "terminal-bash"
    }
  },
  "terminal.integrated.defaultProfile.windows": "Git-Bash"

  // "terminal.integrated.automationProfile.windows": {

  // }
  // "terminal.integrated.env.osx": {
  // "PYTHONPATH": "${workspaceFolder}",
  // },
  // "terminal.integrated.env.linux": {
  //     "PYTHONPATH": "${workspaceFolder}",
  // },
  // "terminal.integrated.env.windows": {
  //     "PYTHONPATH": "${workspaceFolder}",
  // },
  // "code-runner.runInTerminal": true,
  // "python.terminal.executeInFileDir": true,
  // "workbench.editorAssociations": [

  //     {
  //         "viewType": "jupyter.notebook.ipynb",
  //         "filenamePattern": "*.ipynb"
  //     }
  // ]
}


我想要达到的结果

想要设置根目录。

  • 写回答

2条回答 默认 最新

  • dlliang14 2023-04-07 10:54
    关注

    我知道了。。。下面json下面那段我以为没用,注释了。结果是需要重启vscode才有用。把注释去掉,重启vscode就行了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 4月15日
  • 已采纳回答 4月7日
  • 创建了问题 4月7日

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。