简体   繁体   中英

Debug python module in another directory in Visual Studio Code

I am trying to debug in Visual Studio Code a simple python program that imports a module from a different directory. It keeps giving me ModuleNotFoundError.

in /script/myProg.py, I am calling a function that resides in /lib/hello.py. It runs fine but when I debug it, it raises exception.

Sorry I can't post images directly in the questions yet, but I have screen capped everything below:

/script/myProg.py

/lib/hello.py

launch.json

file structure

error message

I added the below code before the import and it's working.

import sys sys.path.insert(0,'')

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