简体   繁体   中英

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.

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

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'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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