简体   繁体   English

PyInstaller ImportError:没有名为spiderloader的模块

[英]PyInstaller ImportError: No module named spiderloader

Trying to create exe file from my Scrapy project. 尝试从我的Scrapy项目创建exe文件。 I've created main.py file in the root of Scrapy project: 我已经在Scrapy项目的根目录中创建了main.py文件:

from scrapy.crawler import CrawlerProcess
from engine_bot.engine_bot.spiders.main_spider import MainSpider


if __name__ == '__main__':
    process = CrawlerProcess({'BOT_NAME':'engine_bot',
    'SPIDER_MODULES':['engine_bot.engine_bot.spiders'],
    'NEWSPIDER_MODULE':'engine_bot.engine_bot.spiders',
    'ROBOTSTXT_OBEY':False,
    'DOWNLOAD_DELAY':0.20,
    'LOG_FILE':'scrapy.log',
    'LOG_LEVEL':'INFO',
    'ITEM_PIPELINES':{
    'engine_bot.engine_bot.pipelines.XmlExportPipeline': 300,
    }
    })
    process.crawl(MainSpider)
    process.start()

And created a main.exe : pyinstaller --onefile main.py 并创建了一个main.exepyinstaller --onefile main.py

When I run main.exe it raises: 当我运行main.exe它会引发:

Traceback (most recent call last):
  File "bot\main.py", line 14, in <module>
  File "site-packages\scrapy\crawler.py", line 243, in __init__
  File "site-packages\scrapy\crawler.py", line 134, in __init__
  File "site-packages\scrapy\crawler.py", line 320, in _get_spider_loader
  File "site-packages\scrapy\utils\misc.py", line 44, in load_object
  File "importlib\__init__.py", line 37, in import_module
ImportError: No module named spiderloader
[10280] Failed to execute script main

Tried without --onefile with the same result. 尝试不带--onefile的结果相同。 Do you know what to do? 你知道该怎么办吗?

I use pyinstaller -F filename.py --hidden-import spiderloader and after pass this case will stuck in other module too, so I add many hidden import. 我使用pyinstaller -F filename.py --hidden-import spiderloader ,通过后这种情况也会卡在其他模块中,因此我添加了许多隐藏的导入。

For me this work. 对我来说,这项工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM