相关疑难解决方法(0)

ImportError:导入mechanize时没有名为'_version'的模块

我通过pip安装了mechanize并在导入模块时获得了错误:

$ python
Python 3.5.2 (default, Jun 28 2016, 08:46:01) 
[GCC 6.1.1 20160602] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mechanize
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.5/site-packages/mechanize/__init__.py", line 119, in <module>
    from _version import __version__
ImportError: No module named '_version'
Run Code Online (Sandbox Code Playgroud)

该文件-version.py存在于site-packages目录中:

$ ls /usr/lib/python3.5/site-packages/mechanize
_auth.py               __init__.py           _response.py
_beautifulsoup.py      _lwpcookiejar.py      _rfc3986.py
_clientcookie.py       _markupbase.py        _sgmllib_copy.py
_debug.py              _mechanize.py         _sockettimeout.py
_firefox3cookiejar.py  _mozillacookiejar.py  _testcase.py
_form.py               _msiecookiejar.py     _urllib2_fork.py
_gzip.py               _opener.py            _urllib2.py …
Run Code Online (Sandbox Code Playgroud)

python import mechanize python-3.x

4
推荐指数
1
解决办法
9544
查看次数

标签 统计

import ×1

mechanize ×1

python ×1

python-3.x ×1