ete
ete copied to clipboard
ncbiquery fuzzy support not compiled when installed via pip install
When installing ete3 with pip, the sqlite extension required for fuzzy matching (Levenshtein module) is not compiled causing code to fail.
If this is by design (sqlite-dev not a dependency), perhaps a more graceful error message could be added. It would be useful to instruct the user on what needs to be done if the code fails to find the required library. Alternatively, the code could try to compile it on first run if not already available.
thanks @unode, we kept this feature uncompiled on purpose, to make the whole package more portable...and because almost nobody requested the feature. But now that the anaconda ete3 package is ready, we could think of distributing with this module enabled...
If anyone bumps into this error and is lost about what to do, the solution is to navigate to the folder .../ete3/ncbi_taxonomy/SQLite-Levenshtein/
and run make
.
If no error appears (i.e. if all necessary dependencies are installed) it should create the necessary library and the code should no longer complain.
Got this error with ete 3.1.2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pguerin/miniconda3/envs/pylib_cbdr/lib/python3.9/site-packages/ete3/ncbi_taxonomy/ncbiquery.py", line 165, in get_fuzzy_name_translation
_db.execute("select load_extension('%s')" % os.path.join(module_path,
sqlite3.OperationalError: /home/pguerin/miniconda3/envs/pylib_cbdr/lib/python3.9/site-packages/ete3/ncbi_taxonomy/SQLite-Levenshtein/levenshtein.sqlext.so: cannot open shared object file: No such file or directory
I applied the recommandation of @unode
ncbi.get_fuzzy_name_translation(name="Albula forsteri")
Trying fuzzy search for Albula forsteri
This is working fine now. Yet I would like a nice error message telling me to compile the missing feature.
@unode I'm running into the same error, I tried running the make command but I get a fatal error. is there any way to install the sqlite extension so it compiles fine?
This is the summary of my issue https://www.reddit.com/r/learnpython/comments/uoefez/help_with_project_ncbi_database/
(base) jespinozlt2-osx:~ jespinoz$ cd /Users/jespinoz/anaconda3/envs/soothsayer_py3.9_env2/lib/python3.9/site-packages/ete3/ncbi_taxonomy/SQLite-Levenshtein/
(base) jespinozlt2-osx:SQLite-Levenshtein jespinoz$ ls
EXAMPLE Makefile README src tests
(base) jespinozlt2-osx:SQLite-Levenshtein jespinoz$ make
gcc -Wall -shared -fPIC -Isqlite3 -o levenshtein.sqlext src/levenshtein.c
src/levenshtein.c:4:10: fatal error: 'malloc.h' file not found
#include <malloc.h>
^~~~~~~~~~
1 error generated.
make: *** [levenshtein.sqlext] Error 1