gpt4 book ai didi

python - 为什么我在使用 IMDbPY 时会收到这么多警告和一些错误?

转载 作者:太空宇宙 更新时间:2023-11-03 11:35:18 25 4
gpt4 key购买 nike

我正在使用 IMDbPY从 IMDb 检索数据。我得到了正确的结果,一切看起来都很好,除了一件事:无论我做什么,我都会收到警告。结果很好,但它们仅在一长串警告(有时是错误)之后出现。

例如:下面的代码应该打印Resevior Dogs (1992):

import imdb
db = imdb.IMDb()
movie_obj = db.search_movie('pulp fiction')[0]
db.update(movie_obj)
print movie_obj['long imdb canonical title']

它会这样做,但不会在出现以下警告和错误之前:

2011-03-18 00:33:11,490 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:459: unable to use "lxml": No module named lxml.html
2011-03-18 00:33:11,507 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:450: falling back to "beautifulsoup"
2011-03-18 00:33:13,483 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:459: unable to use "lxml": No module named lxml.html
2011-03-18 00:33:13,483 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:450: falling back to "beautifulsoup"
2011-03-18 00:33:15,137 ERROR [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:566: DOMHTMLMovieParser: caught exception extracting XPath "//div[@id='tn15title']//span[starts-with(text(), 'TV series')]"
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\imdb\parser\http\utils.py", line 555, in xpath
xpath_result = element.xpath(path)
File "C:\Python27\lib\site-packages\imdb\parser\http\bsouplxml\etree.py", line 57, in xpath
return path.apply(node)
File "C:\Python27\lib\site-packages\imdb\parser\http\bsouplxml\bsoupxpath.py", line 113, in apply
nodes = step.apply(nodes)
File "C:\Python27\lib\site-packages\imdb\parser\http\bsouplxml\bsoupxpath.py", line 287, in apply
found = filter(checker, found)
File "C:\Python27\lib\site-packages\imdb\parser\http\bsouplxml\bsoupxpath.py", line 331, in __call__
return self.__filter(node)
File "C:\Python27\lib\site-packages\imdb\parser\http\bsouplxml\bsoupxpath.py", line 360, in __starts_with
first = node.contents[0]
IndexError: list index out of range
2011-03-18 00:33:16,785 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:459: unable to use "lxml": No module named lxml.html
2011-03-18 00:33:16,785 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:450: falling back to "beautifulsoup"
2011-03-18 00:33:16,849 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:459: unable to use "lxml": No module named lxml.html
2011-03-18 00:33:16,849 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:450: falling back to "beautifulsoup"

为什么我会得到这个?我做错了什么吗?

最佳答案

好吧,这是不言自明的:

unable to use "lxml": No module named lxml.html

你能这样做来检查模块是否存在吗?

  1. 在终端或命令提示符中,运行 python
  2. 发布第一行的输出(例如 Python 2.6.6 (r266...)。
  3. 在 shell 中,输入 import lxml
  4. 接下来,尝试import lxml.html

对我来说,这就是发生的事情:

blender@desktop:~$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml
>>> import lxml.html
>>>

我已经安装了模块,所以我没有得到任何输出(已成功导入)。

关于python - 为什么我在使用 IMDbPY 时会收到这么多警告和一些错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5346144/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com