Skip to content

Improve error message when importing missing package extras #155

Description

@vdusek

When installing crawlee like this:

pip install crawlee

And then importing BeautifulSoupCrawler.

I would get just a general ImportError.

Add some import checks and print user-friendly error messages. E.g.:

try:
    from bs4 import BeautifulSoup
except ImportError as exc:
    raise ImportError(
        'To use this module, you need to install the "beautifulsoup" extra. Run "pip install crawlee[beautifulsoup]".',
    ) from exc

Check https://github.com/apify/apify-sdk-python/blob/master/src/apify/scrapy/scheduler.py#L5:L13 as inspiration.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request.t-toolingIssues with this label are in the ownership of the tooling team.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions