我在Python 2.7.6導入錯誤:沒有在Python命名_CRFPP模塊2.7.6
安裝CRF ++ 0.58當我嘗試導入我有以下消息:
>>> import CRFPP
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "CRFPP.py", line 42, in <module>
_CRFPP = swig_import_helper()
File "CRFPP.py", line 34, in swig_import_helper
import _CRFPP
ImportError: No module named _CRFPP
>>>
的過程安裝在CRF ++ 0.58的蟒目錄中的自述文件中描述,並且是:
$ python setup.py build
$ sudo python setup.py install
這放置在目錄/usr/local/lib/python2.7/dist-packages/:
- CRFPP.py
- CRFPP.pyc
_CRFPP.so
目錄/usr/local/lib/python2.7/dist-packages/是在sys.path中
在CRFPP.py在安裝目錄包含在其開始,以下過程:
#This file was automatically generated by SWIG (http://www.swig.org). # Version 2.0.4 # # Do not make changes to this file unless you know what you are doing--modify # the SWIG interface file instead. from sys import version_info if version_info >= (2,6,0): def swig_import_helper(): from os.path import dirname import imp fp = None try: fp, pathname, description = imp.find_module('_CRFPP',[dirname(__file__)]) except ImportError: import _CRFPP return _CRFPP if fp is not None: try: _mod = imp.load_module('_CRFPP', fp, pathname, description) finally: fp.close() return _mod _CRFPP = swig_import_helper() del swig_import_helper else: import _CRFPP del version_info
小鬼沒有找到_CRFPP.so,卻發現CRFPP.py:
>>> import imp
>>> imp.find_module("_CRFPP")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named _CRFPP
>>> imp.find_module("CRFPP")
(<open file '/usr/local/lib/python2.7/dist-packages/CRFPP.py', mode 'U' at 0x7f7748e4a540>, '/usr/local/lib/python2.7/dist-packages/CRFPP.py', ('.py', 'U', 1))