问题描述
我在使用美丽汤的Google应用引擎中制作了一个应用。我正在使用它的最新版本,。一切工作正常,直到我上传到GAE。然后发生的事情是我得到了这个错误:
pre code $ Traceback最近一次调用最后一次
文件 /base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py,第701行,在__call__
handler.get(* groups)
文件/ base / data /home/apps/s~app/1.358226218191077920/main.py,第285行,获取
self.response.out.write(self.makeQuery(9147094591))
File/ base /data/home/apps/s~app/1.358226218191077920/main.py,第191行,在makeQuery中
导入BeautifulSoup
文件/ base / data / home / apps / s〜app / 1.358226218191077920 / bs4 / __ init__.py,第29行,在< module>
from .builder import builder_registry
文件/base/data/home/apps/s~app/1.358226218191077920/bs4/builder/__init__.py,第279行,位于< module>
来自。 import _htmlparser
文件/base/data/home/apps/s~app/1.358226218191077920/bs4/builder/_htmlparser.py,第23行,位于< module>
from bs4.element import(
文件/base/data/home/apps/s~app/1.358226218191077920/bs4/element.py,第6行,位于< module>
from bs4.dammit import EntitySubstitution
文件/base/data/home/apps/s~app/1.358226218191077920/bs4/dammit.py,第254行
smart_quotes_re = b([\x80- \ x9f])
^
SyntaxError:无效语法
当我看看dammit.py中的第254行,我发现这个:
if(self.smart_quotes_to不是None
并且提议($)中的.lower()在self.ENCODINGS_WITH_SMART_QUOTES):
smart_quotes_re = b([\x80-\x9f])
smart_quotes_compiled = re.compile(smart_quotes_re)
markup = smart_quotes_compiled。 sub(self._sub_ms_char,markup)
我真的不明白什么是错的。尝试过其他版本的BS,但他们不工作,因为我使用的只是se的soup.select(CSS SELECTOR) ems工作在最新版本。不过,正如我刚才所说,它在我的电脑上运行良好,但不在云端。
BeautifulSoup 4需要Python 2.7或更新版本,但Appengine默认使用Python 2.5。您可以:
- 现在使用BeautifulSoup 3。
I have made an application in Google app engine that is using Beautiful Soup. I'm using the latest version of it, http://www.crummy.com/software/BeautifulSoup/bs4/download/4.0/. Everything worked fine until i uploaded it to GAE. The thing that happend then was that I got this error:
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 701, in __call__
handler.get(*groups)
File "/base/data/home/apps/s~app/1.358226218191077920/main.py", line 285, in get
self.response.out.write(self.makeQuery("9147094591"))
File "/base/data/home/apps/s~app/1.358226218191077920/main.py", line 191, in makeQuery
from bs4 import BeautifulSoup
File "/base/data/home/apps/s~app/1.358226218191077920/bs4/__init__.py", line 29, in <module>
from .builder import builder_registry
File "/base/data/home/apps/s~app/1.358226218191077920/bs4/builder/__init__.py", line 279, in <module>
from . import _htmlparser
File "/base/data/home/apps/s~app/1.358226218191077920/bs4/builder/_htmlparser.py", line 23, in <module>
from bs4.element import (
File "/base/data/home/apps/s~app/1.358226218191077920/bs4/element.py", line 6, in <module>
from bs4.dammit import EntitySubstitution
File "/base/data/home/apps/s~app/1.358226218191077920/bs4/dammit.py", line 254
smart_quotes_re = b"([\x80-\x9f])"
^
SyntaxError: invalid syntax
When I look at line 254 in dammit.py I find this:
if (self.smart_quotes_to is not None
and proposed.lower() in self.ENCODINGS_WITH_SMART_QUOTES):
smart_quotes_re = b"([\x80-\x9f])"
smart_quotes_compiled = re.compile(smart_quotes_re)
markup = smart_quotes_compiled.sub(self._sub_ms_char, markup)
I can't really see what is wrong. I've tried other versions of BS but they don't work because I'm using the soup.select("CSS SELECTOR") which only seems to work in the latest version.
But, as I said earlier, it worked fine on my computer but not in the cloud.
BeautifulSoup 4 needs Python 2.7 or newer, but Appengine has Python 2.5 by default. You can either:
Use Python 2.7 on Appengine (Edit: doesn't require a paid app. Thanks Grewe.)
Use BeautifulSoup 3 for now.
这篇关于谷歌appengine的BeautifulSoup错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!