diff --git a/scrapy/commands/runspider.py b/scrapy/commands/runspider.py index a8db1cd86..ed16c3fb6 100644 --- a/scrapy/commands/runspider.py +++ b/scrapy/commands/runspider.py @@ -12,9 +12,9 @@ from scrapy.commands import BaseRunSpiderCommand def _import_file(filepath: Union[str, PathLike]) -> ModuleType: abspath = Path(filepath).resolve() - dirname = str(abspath.parent) if abspath.suffix not in ('.py', '.pyw'): raise ValueError(f"Not a Python source file: {abspath}") + dirname = str(abspath.parent) if dirname: sys.path = [dirname] + sys.path try: