我已经使用pip安装了pymorphy2:
Requirement already satisfied (use --upgrade to upgrade): pymorphy2 in /usr/local/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): docopt>=0.6 in /usr/local/lib/python2.7/site-packages (from pymorphy2)
Requirement already satisfied (use --upgrade to upgrade): pymorphy2-dicts<3.0,>=2.4 in /usr/local/lib/python2.7/site-packages (from pymorphy2)
但是当我试图在Python交互式shell中导入这个库时,我得到了这个:
>>> import pymorphy2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/pymorphy2/__init__.py", line 3, in <module>
from .analyzer import MorphAnalyzer
File "/usr/local/lib/python2.7/site-packages/pymorphy2/analyzer.py", line 10, in <module>
from pymorphy2 import opencorpora_dict
File "/usr/local/lib/python2.7/site-packages/pymorphy2/opencorpora_dict/__init__.py", line 4, in <module>
from .storage import load_dict as load
File "/usr/local/lib/python2.7/site-packages/pymorphy2/opencorpora_dict/storage.py", line 24, in <module>
from pymorphy2.utils import json_write, json_read
File "/usr/local/lib/python2.7/site-packages/pymorphy2/utils.py", line 5, in <module>
import bz2
ImportError: No module named bz2
好的,没问题:
sudo apt-get install libbz2-dev
最后:
maestro@UIServer:~$ sudo apt-get install libbz2-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libbz2-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 64 not upgraded.
1 not fully installed or removed.
After this operation, 0B of additional disk space will be used.
Setting up python-pip (0.3.1-1ubuntu2) ...
Traceback (most recent call last):
File "/usr/bin/pycentral", line 2196, in <module>
main()
File "/usr/bin/pycentral", line 2190, in main
rv = action.run(global_options)
File "/usr/bin/pycentral", line 1478, in run
runtimes = get_installed_runtimes()
File "/usr/bin/pycentral", line 279, in get_installed_runtimes
default_version = pyversions.default_version(version_only=True)
File "/usr/share/pycentral-data/pyversions.py", line 172, in default_version
raise ValueError, "/usr/bin/python does not match the python default version. It must be reset to point to %s" % debian_default
ValueError: /usr/bin/python does not match the python default version. It must be reset to point to python2.6
dpkg: error processing python-pip (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
python-pip
E: Sub-process /usr/bin/dpkg returned an error code (1)
在我的案例中如何解决与python版本的这种冲突?
答案 0 :(得分:0)
看起来你需要为python 2.6创建一个新的符号链接。
ln -sf /usr/bin/python2.6 /usr/bin/python