Py2exe doesn't find bs4

无人久伴 提交于 2019-12-02 19:22:18

问题


In my original code, I have the line:

from bs4 import BeautifulSoup

When I use py2exe, it builds fine but further up in the output it says:

The following modules appear to be missing
['_scproxy', 'bs4']

I specifically put bs4 in the py2exe options:

"includes": ["bs4.BeautifulSoup"]

Is that how I should be referencing BeautifulSoup in the includes statement? The fella over here didn't know how to do it either: 3rd Party Libraries and Py2exe

Do I need to use packages instead of includes or something? All regular libraries and some other like mechanize import fine, but I can't get BeautifulSoup to work fine. Any advice is appreciated.

EDIT: I solved part of this by uninstall BeautifulSoup and re-installing with --always-unzip option:

easy_install --always-unzip beautifulsoup4

However, it added 9 new missing modules. One being '_scproxy'.


回答1:


First thing to check is that you have your setup.py in the same directory as your module and your are running it from that directory.

If that doesn't work your should add your module to your path in setup.py:

module_path = r'path\to\your\BeautifulSoup\module'
if module_path not in sys.path:
    sys.path.append(modules_path)


来源:https://stackoverflow.com/questions/21167026/py2exe-doesnt-find-bs4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!