Re: Trouble installing BS4 on Linux webserver

62 views
Skip to first unread message

dynamicfx

unread,
Sep 19, 2012, 11:18:19 PM9/19/12
to beauti...@googlegroups.com
I think I figured out the problem --
The webserver is running python 2.4.3, and it looks like bs4 is only supported on 2.6+.  So I installed BS3 and things seem to be working (with a few syntax changes in the code).  I don't have control over what python version they're running, though I'll see if they can upgrade, as I like the newer changes in bs4.

Anyway, nevermind - thanks!
Alan



On Wednesday, September 19, 2012 3:45:36 PM UTC-7, dynamicfx wrote:
I played around with bs4 on my Windows machine yesterday and was able to get it to install and work immediately without any problems.  Then I tried installing it on my webhost server (Linux) today, where I don't have all the root privileges for everything, so I have to keep things in my home dir area, but I'm getting errors.  Here's my process:

[~/lib/python]% tar -xvf beautifulsoup4-4.1.3.tar
[~/lib/python]% cd beautifulsoup4-4.1.3
[~/lib/python]% python setup.py install --home=~
running install
running build
running build_py
running install_lib
creating ~/lib/python/bs4
creating ~/lib/python/bs4/builder
copying build/lib/bs4/builder/_htmlparser.py -> ~/lib/python/bs4/builder
copying build/lib/bs4/builder/_lxml.py -> ~/lib/python/bs4/builder
copying build/lib/bs4/builder/__init__.py -> ~/lib/python/bs4/builder
copying build/lib/bs4/builder/_html5lib.py -> ~/lib/python/bs4/builder
copying build/lib/bs4/testing.py -> ~/lib/python/bs4
copying build/lib/bs4/dammit.py -> ~/lib/python/bs4
copying build/lib/bs4/__init__.py -> ~/lib/python/bs4
copying build/lib/bs4/element.py -> ~/lib/python/bs4
creating ~/lib/python/bs4/tests
copying build/lib/bs4/tests/test_docs.py -> ~/lib/python/bs4/tests
copying build/lib/bs4/tests/test_tree.py -> ~/lib/python/bs4/tests
copying build/lib/bs4/tests/test_html5lib.py -> ~/lib/python/bs4/tests
copying build/lib/bs4/tests/__init__.py -> ~/lib/python/bs4/tests
copying build/lib/bs4/tests/test_lxml.py -> ~/lib/python/bs4/tests
copying build/lib/bs4/tests/test_builder_registry.py -> ~/lib/python/bs4/tests
copying build/lib/bs4/tests/test_soup.py -> ~/lib/python/bs4/tests
copying build/lib/bs4/tests/test_htmlparser.py -> ~/lib/python/bs4/tests
byte-compiling ~/lib/python/bs4/builder/_htmlparser.py to _htmlparser.pyc
byte-compiling ~/lib/python/bs4/builder/_lxml.py to _lxml.pyc
byte-compiling ~/lib/python/bs4/builder/__init__.py to __init__.pyc
  File "~/lib/python/bs4/builder/__init__.py", line 303
    from . import _htmlparser
         ^
SyntaxError: invalid syntax
byte-compiling ~/lib/python/bs4/builder/_html5lib.py to _html5lib.pyc
byte-compiling ~/lib/python/bs4/testing.py to testing.pyc
  File "~/lib/python/bs4/testing.py", line 106
    markup = b"""<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Hello.</title></head>
<body>Goodbye.</body>
</html>"""


         ^
SyntaxError: invalid syntax
byte-compiling ~/lib/python/bs4/dammit.py to dammit.pyc
  File "~/lib/python/bs4/dammit.py", line 281
    smart_quotes_re = b"([\x80-\x9f])"
                                     ^
SyntaxError: invalid syntax
byte-compiling ~/lib/python/bs4/__init__.py to __init__.pyc
  File "~/lib/python/bs4/__init__.py", line 29
    from .builder import builder_registry
         ^
SyntaxError: invalid syntax
byte-compiling ~/lib/python/bs4/element.py to element.pyc
byte-compiling ~/lib/python/bs4/tests/test_docs.py to test_docs.pyc
byte-compiling ~/lib/python/bs4/tests/test_tree.py to test_tree.pyc
  File "~/lib/python/bs4/tests/test_tree.py", line 672
    self.assertEqual(b"<br/>", xml_br.encode())
                            ^
SyntaxError: invalid syntax
byte-compiling ~/lib/python/bs4/tests/test_html5lib.py to test_html5lib.pyc
  File "~/lib/python/bs4/tests/test_html5lib.py", line 20
    class HTML5LibBuilderSmokeTest(SoupTest, HTML5TreeBuilderSmokeTest):
        ^
SyntaxError: invalid syntax
byte-compiling ~/lib/python/bs4/tests/__init__.py to __init__.pyc
byte-compiling ~/lib/python/bs4/tests/test_lxml.py to test_lxml.pyc
  File "~n/lib/python/bs4/tests/test_lxml.py", line 29
    class LXMLTreeBuilderSmokeTest(SoupTest, HTMLTreeBuilderSmokeTest):
        ^
SyntaxError: invalid syntax
byte-compiling ~/lib/python/bs4/tests/test_builder_registry.py to test_builder_registry.pyc
byte-compiling ~/lib/python/bs4/tests/test_soup.py to test_soup.pyc
  File "~/lib/python/bs4/tests/test_soup.py", line 37
    with warnings.catch_warnings(record=True) as w:
                ^
SyntaxError: invalid syntax
byte-compiling ~/lib/python/bs4/tests/test_htmlparser.py to test_htmlparser.pyc
------------------------------------------------------------------------

(BTW, I text rep'd my home dir with ~ in the output above, for privacy.)

I also tried just copying the bs4 dir out to the ~/lib/python area directly, but I get this error when trying to run my script:

Traceback (most recent call last):
  File "./test_bs.py", line 3, in ?
    from bs4 import BeautifulSoup
  File "~/lib/python/bs4/__init__.py", line 29
    from .builder import builder_registry
         ^
SyntaxError: invalid syntax
-----------------------------------------

Any ideas what would be causing those issues?

Thanks for any help!
Alan

Reply all
Reply to author
Forward
0 new messages