Reputation: 1
I installed CRF++0.58 in Python 2.7.6
When I try to import I have the following message:
>>> 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
>>>
The procedure to install is described in the README file in python directory of CRF++0.58, and is:
$ python setup.py build
$ sudo python setup.py install
This placed in the directory /usr/local/lib/python2.7/dist-packages/ :
_CRFPP.so
The directory /usr/local/lib/python2.7/dist-packages/ is in the sys.path
In the CRFPP.py in the setup directory contains, in its begin, the following procedure:
#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
imp does not find _CRFPP.so, but found 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))
Upvotes: 0
Views: 1753
Reputation: 1
The solution is in:
Python error "ImportError: No module named"
Answer: https://stackoverflow.com/a/23964457/5283795
posted in May 30 '14 at 22:50 by KrisWebDev :
sudo chmod 755 /usr/local/lib/python2.7/dist-packages/*.so
After this I imported the module.
Initially the module was with the following attributes:
-rwxrwx--- 1 root staff 255671 Jul 22 2014 _CRFPP.so
After the command:
-rwxr-xr-x 1 root staff 255671 Jul 22 2014 _CRFPP.so
Upvotes: 0