Asif Iqbal
Asif Iqbal

Reputation: 1

During debugging in pycharm "ModuleNotFoundError" appears

enter image description hereThis is the first time I am debugging my code. Although pycharm successfully recommended me the name of the module, but when I debug the code it is saying module not found error. Need help

Upvotes: -1

Views: 203

Answers (1)

mdaniel
mdaniel

Reputation: 33223

You are launching runner inside the glassesshop directory, so from its perspective there is only one glassesshop package, not the two that are from the eye-glasses project's perspective

Change your PyCharm run configuration to launch in the $PROJECT_DIR$ directory, and then the script would be glassesshop/runner.py or, of course, move your runner.py up one directory


While this isn't what you asked, you can also debug your spider just like normal Python code -- without involving all the Scrapy machinery -- by putting a main at the bottom of your Spider and running it normally; the same trick would work with unittest or pytest, if you wanted more formal verification

class MySpider(Spider):
   def parse(self, response):
      pass

if __name__ == '__main__':
    with open("a-sample-response.html") as fh:
        html = fh.read()
    req = Request(url="https://example.com")
    resp = HtmlResponse(url=req.url, request=req, body=html)
    s = MySpider()
    s.parse(resp)

Upvotes: 1

Related Questions