KlugerLab / GeneTrajectory

R implementation of GeneTrajectory
https://www.nature.com/articles/s41587-024-02186-3
45 stars 9 forks source link

"How to resolve the error encountered during the process of importing the function to compute gene-gene distances?" #12

Open maaa-a opened 3 months ago

maaa-a commented 3 months ago

"When I was working on computing gene-gene distances, I encountered this error. How can I resolve it? Thank you." cal_ot_mat_from_numpy <- reticulate::import('gene_trajectory.compute_gene_distance_cmd')$cal_ot_mat_from_numpy error in py_module_import(module, convert = convert): ImportError: numpy.core.multiarray failed to import (auto-generated because you didn't call 'numpy.import_array()' after cimporting numpy; use 'numpy._import_array' to disable if you are certain you don't need it).

fra-pcmgf commented 3 months ago

Hi @maaa-a

It looks like there are issues with your Python environment and the installation of numpy.

Are you using conda or virtualenv? Can you check the version of Python and numpy you are using? To get the values, start a new R session, pick the environment to use with reticulate (e.g. reticulate::use_virtualenv('igt')) and then run reticulate::py_config().

If you have an older version of numpy, updating may solve the issue

maaa-a commented 3 months ago

"I've been using the latest versions of Python and numpy. If I need to use another version. version: 3.12.4 (tags/v3.12.4:8e8a4ba, Jun 6 2024, 19:30:16) numpy_version: 2.0.0

fra-pcmgf commented 3 months ago

It seems like numpy 2.0 has introduced some non-breaking changes. Try downgrading numpy (e.g. reticulate::py_install('numpy<2.0' ) )

I have created an issue on the Python project (https://github.com/KlugerLab/GeneTrajectory-python/issues/12) to try and make the package compatible with numpy 2.0 and 1.26.