gpt4 book ai didi

python - 导入 python3 的 mechanize 分支时出错

转载 作者:行者123 更新时间:2023-11-28 16:38:39 25 4
gpt4 key购买 nike

我已经为 python3 安装了 mechanize 库。 https://github.com/adevore/mechanize/tree/python3

但是,当我导入它时,出现此错误。

Python 3.3.3 (default, Dec 30 2013, 16:15:14) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import mechanize
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/Username/.virtualenvs/python3/lib/python3.3/site-packages/mechanize-0.2.6.dev_20140305-py3.3.egg/mechanize/__init__.py", line 122, in <module>
File "/Users/Username/.virtualenvs/python3/lib/python3.3/site-packages/mechanize-0.2.6.dev_20140305-py3.3.egg/mechanize/_mechanize.py", line 15, in <module>
File "/Users/Username/.virtualenvs/python3/lib/python3.3/site-packages/mechanize-0.2.6.dev_20140305-py3.3.egg/mechanize/_html.py", line 16, in <module>
ImportError: cannot import name _sgmllib_copy

但是,我确信 mechanize 安装在同一个 virtualenv 目录中。

$ pip freeze
## FIXME: could not find svn URL in dependency_links for this package:
mechanize==0.2.6.dev-20140305
pyquery==1.2.8
Warning: cannot find svn location for mechanize==0.2.6.dev-20140305

我不习惯在终端操作,所以我不知道如何解决这个问题。

谁能帮我解决这个问题?

提前致谢!

最佳答案

您引用的 git 存储库使用了错误的 importmechanize._html 模块 import_sgmllib_copy 期望获得 mechanize._sgmllib_copy,但是这种导入方式有在 PEP 328 中已弃用.相反,它应该使用相对导入,例如来自 .导入 _sgmllib_copy

关于python - 导入 python3 的 mechanize 分支时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22496112/

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