python解决机械问题_导入机械化时出现python3错误

I get an error in python3 when importing mechanize.

I've just installed mechanize into my virtualenv where python3 is installed.

$ which python3

/Users/myname/.virtualenvs/python3/bin/python3

$ pip freeze

mechanize==0.2.5

But, when I try to import mechanize in my python code, I get this error.

import mechanize

---------------------------------------------------------------------------

ImportError Traceback (most recent call last)

in ()

----> 1 import mechanize

/Users/myname/.virtualenvs/python3/lib/python3.3/site-packages/mechanize/__init__.py in ()

117 import sys

118

--> 119 from _version import __version__

120

121 # high-level stateful browser-style interface

ImportError: No module named '_version'

Does anyone know how to fix this problem?

I'm new to python and I've been studying how to program in python these days.

Thanks for your help in advance!

update

I've installed mechanize for python3.

Now, I have an another error.

In [1]: import mechanize

---------------------------------------------------------------------------

ImportError Traceback (most recent call last)

in ()

----> 1 import mechanize

/Users/myname/.virtualenvs/python3/lib/python3.3/site-packages/mechanize-0.2.6.dev_20140305-py3.3.egg/mechanize/__init__.py in ()

120

121 # high-level stateful browser-style interface

--> 122 from ._mechanize import \

123 Browser, History, \

124 BrowserStateError, LinkNotFoundError, FormNotFoundError

/Users/myname/.virtualenvs/python3/lib/python3.3/site-packages/mechanize-0.2.6.dev_20140305-py3.3.egg/mechanize/_mechanize.py in ()

/Users/myname/.virtualenvs/python3/lib/python3.3/site-packages/mechanize-0.2.6.dev_20140305-py3.3.egg/mechanize/_html.py in ()

ImportError: cannot import name _sgmllib_copy

I checked what I've installed in my working virtualenv.

I found some warnings.

$ pip freeze

cssselect==0.9.1

httplib2==0.8

ipython==1.1.0

lxml==3.2.4

## 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

解决方案Python 2.4, 2.5, 2.6, or 2.7. Python 3 is not yet supported.

Update: I wrote my own automating library MechanicalSoup. It's Python 3 compatible https://github.com/hickford/MechanicalSoup

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值