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

末鹿安然 提交于 2021-02-11 18:23:26

问题


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.

By selecting the folder as the eclipse file, the interpolator seems to be selected automatically. 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.

Could anyone give a guess/hint? Appreciate it.

enter image description here


回答1:


Two solutions:

One: change the "../log/Hedger.log" to "./log/Hedger.log".

Two: in launch.json file setting '"cwd": "${workspaceFolder}/src",' in "configurations".

Explains:

${cwd} - the task runner's current working directory on startup. The default setting of 'cwd' is the "${workspaceFolder}", in your project means "C:\Development\Optimizer". So, the '../log/Hedger.log' means 'C:\Development\log\Hedger.log'.



来源:https://stackoverflow.com/questions/62777505/relative-path-error-when-migrating-from-eclipse-pydev-into-vs-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!