I am able to run all the scrapy spiders on vs code without any error. But when I try to run the debugger, it raises an exception
No module named scrapy
I am on MacOS. I can properly run scrapy commands from the terminal as well.
Try running your script from cmd in debug mode with
python -m debugpy --listen 5678 --wait-for-client ./__main__.py
Make sure to install it using python -m pip install debugpy
and then configure a launch.json
file in the debugger to attach to the python script listening on port 5678
{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
}
}
The complete file will look something like this
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
}
}
]
}
After that set the breakpoints in your program and start the debugger from vscode
Also check if the version running during the debug is the same used normally, just create a blank file with the following content
import sys
def main():
print(sys.version)
if __name__ == "__main__":
main()
the following will print something like
3.6.9 (default, Jan 26 2021, 15:33:00) \\n[GCC 8.4.0]
Also check from the statusbar at the bottom of vscode if you have the right python version selected.
More on the first part here
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.