问题
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