Debugging a Python Scrapy Project in VSCode

I’ve been working on a small web scraping project using Scrapy in Visual Studio Code using the Python Extension. I’m using a virtualenv with Scrapy installed and my launch.json file looks like this:

<br />
    ...<br />
    {<br />
        &quot;name&quot;: &quot;Scrapy with Integrated Terminal/Console&quot;,<br />
        &quot;type&quot;: &quot;python&quot;,<br />
        &quot;request&quot;: &quot;launch&quot;,<br />
        &quot;stopOnEntry&quot;: true,<br />
        &quot;pythonPath&quot;: &quot;${config.python.pythonPath}&quot;,<br />
        &quot;program&quot;: &quot;/Users/strefethen/.virtualenvs/scrapy/bin/scrapy&quot;,<br />
        &quot;cwd&quot;: &quot;${workspaceRoot}&quot;,<br />
        &quot;args&quot;: [<br />
            &quot;crawl&quot;,<br />
            &quot;specs&quot;,<br />
            &quot;-o&quot;,<br />
            &quot;bikes.json&quot;<br />
        ],<br />
        &quot;console&quot;: &quot;integratedTerminal&quot;,<br />
        &quot;env&quot;: null,<br />
        &quot;envFile&quot;: &quot;${workspaceRoot}/.env&quot;,<br />
        &quot;debugOptions&quot;: [<br />
            &quot;WaitOnAbnormalExit&quot;,<br />
            &quot;WaitOnNormalExit&quot;<br />
        ]<br />
    },<br />
    ...<br />

The key parts are the “cwd” and “args” for calling scrapy to start the crawl. My Workspace setting overrides look like this:
<br />
// Place your settings in this file to overwrite default and user settings.<br />
{<br />
    &quot;python.pythonPath&quot;: &quot;/Users/strefethen/.virtualenvs/scrapy/bin/python&quot;,<br />
    &quot;python.venvPath&quot;: &quot;~/.virtualenv&quot;<br />
}<br />