-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add explicit err msgs for missing pckg extras during import (#165)
## Description - Add explicit error messages for missing package extras during import. - It applies to BrowserPool, BeautifulsoupCrawler, and PlaywrightCrawler. - Also until now the Playwright was mandatory for even `BasicCrawler`, fixing it. ## Related issues - Closes #155 ## Testing ### PlaywrightCrawler ``` ImportError Traceback (most recent call last) Cell In[3], line 1 ----> 1 from crawlee.playwright_crawler import PlaywrightCrawler File ~/Projects/crawlee-py/src/crawlee/playwright_crawler/__init__.py:5 3 from .types import PlaywrightCrawlingContext 4 except ImportError as exc: ----> 5 raise ImportError( 6 'To use this module, you need to install the "playwright" extra. Run "pip install crawlee[playwright]".', 7 ) from exc ImportError: To use this module, you need to install the "playwright" extra. Run "pip install crawlee[playwright]". ``` ### BeautifulsoupCrawler ``` ImportError Traceback (most recent call last) Cell In[1], line 1 ----> 1 from crawlee.beautifulsoup_crawler import BeautifulSoupCrawler File ~/Projects/crawlee-py/src/crawlee/beautifulsoup_crawler/__init__.py:5 3 from .types import BeautifulSoupCrawlingContext 4 except ImportError as exc: ----> 5 raise ImportError( 6 'To use this module, you need to install the "beautifulsoup" extra. Run "pip install crawlee[beautifulsoup]".', 7 ) from exc ImportError: To use this module, you need to install the "beautifulsoup" extra. Run "pip install crawlee[beautifulsoup]". ``` ### BrowserPool ``` ImportError Traceback (most recent call last) Cell In[2], line 1 ----> 1 from crawlee.browsers import BrowserPool File ~/Projects/crawlee-py/src/crawlee/browsers/__init__.py:5 3 from .playwright_browser_plugin import PlaywrightBrowserPlugin 4 except ImportError as exc: ----> 5 raise ImportError( 6 'To use this module, you need to install the "playwright" extra. Run "pip install crawlee[playwright]".', 7 ) from exc ImportError: To use this module, you need to install the "playwright" extra. Run "pip install crawlee[playwright]". ``` ## Checklist - [x] Changes are described in the `CHANGELOG.md` - [x] CI passed
- Loading branch information
Showing
9 changed files
with
83 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
from .beautifulsoup_crawler import BeautifulSoupCrawler | ||
from .types import BeautifulSoupCrawlingContext | ||
try: | ||
from .beautifulsoup_crawler import BeautifulSoupCrawler | ||
from .types import BeautifulSoupCrawlingContext | ||
except ImportError as exc: | ||
raise ImportError( | ||
'To import anything from this subpacakge, you need to install the "beautifulsoup" extra. ' | ||
'For example, if you use pip, run "pip install crawlee[beautifulsoup]".', | ||
) from exc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
from .browser_pool import BrowserPool | ||
from .playwright_browser_plugin import PlaywrightBrowserPlugin | ||
try: | ||
from .browser_pool import BrowserPool | ||
from .playwright_browser_plugin import PlaywrightBrowserPlugin | ||
except ImportError as exc: | ||
raise ImportError( | ||
'To import anything from this subpacakge, you need to install the "playwright" extra. ' | ||
'For example, if you use pip, run "pip install crawlee[playwright]".', | ||
) from exc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
from .playwright_crawler import PlaywrightCrawler | ||
from .types import PlaywrightCrawlingContext | ||
try: | ||
from .playwright_crawler import PlaywrightCrawler | ||
from .types import PlaywrightCrawlingContext | ||
except ImportError as exc: | ||
raise ImportError( | ||
'To import anything from this subpacakge, you need to install the "playwright" extra. ' | ||
'For example, if you use pip, run "pip install crawlee[playwright]".', | ||
) from exc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters