如何在 Google App Engine 和 dev_appserver.py 上使用 BeautifulSoup 和 lxml
how to use BeautifulSoup with lxml on Google App Engine with dev_appserver.py
我做了必要的步骤,我可以 运行 从 shell 成功:
pip install lxml -t lib
cd lib
python
>>> from bs4 import BeautifulSoup
>>> import lxml
>>> res = BeautifulSoup("<p>hello</p>","lxml")
>>> print res
<html><body><p>hello</p></body></html>
但是在 Google App Engine 上 dev_appserver.py
没有成功:
from bs4 import BeautifulSoup
import lxml
import lxml
p1 = BeautifulSoup("<p>toto</p>","lxml")
错误是:
Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
可能是什么问题?
lxml
库是 Python 2.7 运行时的 built-in third-party library,但默认情况下不附带 dev_appserver.py
。您需要在您的机器上单独安装它:
pip install lxml==2.3.5
请参阅 this guide 的 "Using built-in bundled libraries with the local development server" 部分。
部署时,您需要将此添加到 app.yaml
:
libraries:
- name: lxml
version: "2.3.5"
我做了必要的步骤,我可以 运行 从 shell 成功:
pip install lxml -t lib
cd lib
python
>>> from bs4 import BeautifulSoup
>>> import lxml
>>> res = BeautifulSoup("<p>hello</p>","lxml")
>>> print res
<html><body><p>hello</p></body></html>
但是在 Google App Engine 上 dev_appserver.py
没有成功:
from bs4 import BeautifulSoup
import lxml
import lxml
p1 = BeautifulSoup("<p>toto</p>","lxml")
错误是:
Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
可能是什么问题?
lxml
库是 Python 2.7 运行时的 built-in third-party library,但默认情况下不附带 dev_appserver.py
。您需要在您的机器上单独安装它:
pip install lxml==2.3.5
请参阅 this guide 的 "Using built-in bundled libraries with the local development server" 部分。
部署时,您需要将此添加到 app.yaml
:
libraries:
- name: lxml
version: "2.3.5"