Importing bs4 in Python 3.5

前端 未结 3 1506
南旧
南旧 2020-12-18 21:10

I have installed both Python 3.5 and Beautifulsoup4. When I try to import bs4, I get the error below. Is there any fix for that? Or should I just install Python 3.4 instead?

相关标签:
3条回答
  • 2020-12-18 21:35

    Update: BeautifulSoup 4.4.0 has been updated to be python3.5 compatible, so a pip install --upgrade beautifulsoup4 should do the trick if you are still hitting this issue.

    0 讨论(0)
  • 2020-12-18 21:37

    Update: Starting with 4.4.0, BeautifulSoup is compatible with Python 3.5. Upgrade:

    pip install --upgrade beautifulsoup4
    

    Old answer:

    Because of the changes made for Deprecate strict mode of HTMLParser issue:

    Issue #15114: the strict mode and argument of HTMLParser, HTMLParser.error, and the HTMLParserError exception have been removed.

    I'm afraid beautifulSoup4 is not compatible with Python 3.5 at the moment. Use Python 3.4.

    0 讨论(0)
  • 2020-12-18 21:41

    I've sent the author a followup about this bug. If you want to install BeautifulSoup on Python 3.5a, I've uploaded a working patch of the source code to github.

    https://github.com/jjangsangy/BeautifulSoup4

    You can install it using setup.py or just copy & paste this code into terminal.

    git clone https://github.com/jjangsangy/BeautifulSoup4 \
        && cd BeautifulSoup4 \
        && python3.5 setup.py install
    

    I'm assuming here that since you're trying out 3.5a your python interpreter is installed with proper user permissions for your site-packages directory so no sudo invocation is necessary.

    0 讨论(0)
提交回复
热议问题