WojciechMula / pyahocorasick

Python module (C extension and plain python) implementing Aho-Corasick algorithm
BSD 3-Clause "New" or "Revised" License
927 stars 122 forks source link

ImportError: No module named 'ahocorasick' (or pyahocorasick) #96

Closed SeekPoint closed 5 years ago

SeekPoint commented 5 years ago

ub16hp@UB16HP:~/ub16_prj/pyahocorasick$ sudo pip3 install -e . [sudo] password for ub16hp: The directory '/home/ub16hp/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/home/ub16hp/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Obtaining file:///home/ub16hp/ub16_prj/pyahocorasick Installing collected packages: pyahocorasick Found existing installation: pyahocorasick 1.1.10 Uninstalling pyahocorasick-1.1.10: Successfully uninstalled pyahocorasick-1.1.10 Running setup.py develop for pyahocorasick Successfully installed pyahocorasick ub16hp@UB16HP:~/ub16_prj/pyahocorasick$ python3 yk_test_zh.py Traceback (most recent call last): File "yk_test_zh.py", line 1, in import ahocorasick ImportError: No module named 'ahocorasick' ub16hp@UB16HP:~/ub16_prj/pyahocorasick$ python3 yk_test_zh.py Traceback (most recent call last): File "yk_test_zh.py", line 1, in import ahocorasick ImportError: No module named 'ahocorasick' ub16hp@UB16HP:~/ub16_prj/pyahocorasick$

WojciechMula commented 5 years ago

pip3 install -e . places a library file in the current directory. You have to tell the python interpreter to search this directory too:

$ export PYTHONPATH=.
$ python 3
>>> import ahocorasick
WojciechMula commented 5 years ago

BTW, if you're not going to change module's code, it will be easier just to pip3 install pyahocorasick.

SeekPoint commented 5 years ago

no need export PYTHONPATH=.

I found root cause: pip3 work on another version python3