简体   繁体   English

从 Eclipse (PyDev) 迁移到 VS 代码时出现相对路径错误

[英]Relative Path Error When Migrating From Eclipse (PyDev) into VS Code

I am completely new to the VS Code - find it very easy to use compared with Eclipse so I am trying to migrate our existing projects from Eclipse into VS Code.我对 VS Code 完全陌生 - 与 Eclipse 相比,我发现它非常易于使用,因此我正在尝试将我们现有的项目从 Eclipse 迁移到 VS Code。

By selecting the folder as the eclipse file, the interpolator seems to be selected automatically.通过选择文件夹作为 eclipse 文件,似乎自动选择了插值器。 But I do see the error as below.但我确实看到了如下错误。

Exception has occurred: FileNotFoundError
[Errno 2] No such file or directory: 'C:\\Development\\log\\Hedger.log'
  File "C:\Development\Optimizer\src\globals\config.py", line 17, in <module>
    hdlr = logging.FileHandler('../log/Hedger.log') # write log messages to log file
  File "C:\Development\Optimizer\src\run_server.py", line 1, in <module>
    import globals.config as config

Though the actual path should be "C:\Development\Optimizer\log\Hedger.虽然实际路径应该是“C:\Development\Optimizer\log\Hedger.

Could anyone give a guess/hint?谁能给个猜测/提示? Appreciate it.欣赏它。

enter image description here在此处输入图像描述

Two solutions:两种解决方案:

One: change the "../log/Hedger.log" to "./log/Hedger.log".一:将“../log/Hedger.log”改为“./log/Hedger.log”。

Two: in launch.json file setting '"cwd": "${workspaceFolder}/src",' in "configurations".二:在launch.json文件中设置'"cwd": "${workspaceFolder}/src",'在"configurations"中。

Explains:解释:

${cwd} - the task runner's current working directory on startup . ${cwd} - 启动时任务运行器的当前工作目录 The default setting of 'cwd' is the "${workspaceFolder}", in your project means "C:\Development\Optimizer". 'cwd' 的默认设置是“${workspaceFolder}”,在您的项目中意味着“C:\Development\Optimizer”。 So, the '../log/Hedger.log' means 'C:\Development\log\Hedger.log'.因此,“../log/Hedger.log”表示“C:\Development\log\Hedger.log”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM