Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python google appengine中的BeautifulSoup错误_Python_Google App Engine - Fatal编程技术网

Python google appengine中的BeautifulSoup错误

Python google appengine中的BeautifulSoup错误,python,google-app-engine,Python,Google App Engine,我在谷歌应用程序引擎中制作了一个应用程序,它使用的是BeautifulSoup。我正在使用它的最新版本。在我上传到GAE之前,一切都很顺利。当时发生的事情是我犯了这个错误: Traceback (most recent call last): File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 701, in __call__ handler.

我在谷歌应用程序引擎中制作了一个应用程序,它使用的是BeautifulSoup。我正在使用它的最新版本。在我上传到GAE之前,一切都很顺利。当时发生的事情是我犯了这个错误:

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
我真的看不出有什么不对。我尝试过其他版本的BS,但它们不起作用,因为我使用的是soup.select(“CSS选择器”),它似乎只在最新版本中起作用


但是,正如我前面所说的,它在我的计算机上运行良好,但在云中却不行。

BeautifulSoup4需要Python2.7或更高版本,但Appengine默认使用Python2.5。您可以:

  • (编辑:不需要付费应用。谢谢Grewe。)

  • 现在使用BeautifulSoup 3


它不需要付费应用程序。您只需要在
app.yaml
文件中指定它。它还需要您显式地打开或关闭threadsafe。不过,我认为GAE上的2.7仍处于测试阶段。@JoelCornett:@我相信,JoelCornett和所有@JoelCornett 2.7在SDK 1.6.3中都获得了金牌。但是直到SDK1.6.4,由于一些webob依赖的恶作剧已经被修复,您才可以在本地实际开发。
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)