lab-cosmo / librascal

A scalable and versatile library to generate representations for atomic-scale learning
https://lab-cosmo.github.io/librascal/
GNU Lesser General Public License v2.1
80 stars 17 forks source link

ModuleNotFoundError: No module named 'rascal.lib._rascal' #418

Closed Irratzo closed 1 year ago

Irratzo commented 1 year ago

Hi! I installed librascal commit f5f65ea5 successfully in a Docker Ubuntu 20.04 container (including the Compiling step). When I try to use rascal in a Jupyter notebook ...

import rascal
from rascal.representations import *

... I get the following error.

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
/tmp/ipykernel_3598/262286586.py in <cell line: 2>()
      1 import rascal
----> 2 from rascal.representations import *

/opt/librascal/bindings/rascal/representations/__init__.py in <module>
----> 1 from .coulomb_matrix import SortedCoulombMatrix
      2 from .spherical_expansion import SphericalExpansion
      3 from .spherical_invariants import SphericalInvariants
      4 from .spherical_covariants import SphericalCovariants

/opt/librascal/bindings/rascal/representations/coulomb_matrix.py in <module>
      2 import json
      3 
----> 4 from ..neighbourlist import AtomsList
      5 from .base import CalculatorFactory
      6 from itertools import starmap

/opt/librascal/bindings/rascal/neighbourlist/__init__.py in <module>
----> 1 from .structure_manager import (
      2     AtomsList,
      3     get_neighbourlist,
      4     convert_to_structure_list,
      5 )

/opt/librascal/bindings/rascal/neighbourlist/structure_manager.py in <module>
      8 from ase import Atoms
      9 
---> 10 from ..lib import neighbour_list
     11 from .base import (
     12     NeighbourListFactory,

/opt/librascal/bindings/rascal/lib/__init__.py in <module>
----> 1 from ._rascal import neighbour_list, models, representation_calculators, utils
      2 
      3 from ._rascal.models import (
      4     kernels,
      5     compute_sparse_kernel_gradients,

ModuleNotFoundError: No module named 'rascal.lib._rascal'

Here are the installed dependency versions.

- gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
- clang version 10.0.0-4ubuntu1, Target: x86_64-pc-linux-gnu
- cmake version 3.16.3
- Python 3.8.10
- numpy==1.22.4
- scipy==1.8.1
- ase==3.22.1
- Eigen3 3.3.4
- pybind11 v2.3.0
- skcosmo==0.1.2
- sympy==1.11.1

Both the pip install (from repo, branch master) and the compiling (cmake, make), as per instructions, succeeded.

There is no ._rascal module in folder librascal/bindings/rascal/lib/.

What am I doing wrong? Sorry for my inexperience, and thank you for any pointers.

Irratzo commented 1 year ago

Ah. I had installed it in editable mode with pip install -e /opt/librascal, instead of doing cd /opt/librascal and pip install .. With the latter, it worked. Issue closed.

felixmusil commented 1 year ago

The case of an editable install is not somewhat handled properly by design: the package is built in a different folder where the bindings are copied rather than in librascal/bindings/rascal. If you plan on modifying the codebase (python and/or cpp) you might want to follow the step to build the library yourself and add the build folder to your PYTHONPATH. Then after any change, you will have to make so that the changes are appropriately taken into account.