Hello! I am trying to install LAMMPS on a Mac using the macOS terminal. I followed the instructions on lammps.org and built the program using the Cmake commands on 3.1. Build LAMMPS with CMake — LAMMPS documentation . After that I followed the PyLammps quick start tutorial (8.6.3. PyLammps Tutorial — LAMMPS documentation) to build the shared folder and open the PyLammps Jupyter notebooks. However, when I run one of the jupyter notebooks, I get an import error saying there is ‘no module named Lammps’.
The errors seem to be related to the following:
- sys.path is missing some paths
- ld is missing some paths
- run command seems to fail and possible can’t find the path to the lmp command
I have been able to import LAMMPS by appending a path to sys.path, but that leads to further errors running the files, all seem related to the file locations. I have tried adding the export commands (from 2.2. Installation — LAMMPS documentation):
export DYLD_LIBRARY_PATH=$HOME/.local/lib:$DYLD_LIBRARY_PATH
And
export PATH=$HOME/.local/bin:$PATH
Is there any command in the installation I may have missed out, or any reason why I am having so many path errors? Thank you!!!
(EDIT) the commands used for installation are as follows:
Dowloaded from lammps.org
lammps-stable.tar.gz
unzip and untar
tar -xzvf lammps-stable.tar.gz
build LAMMPS with CMake
#go to main LAMMPS directory
cd LAMMPS
mkdir build
cd build
cmake …/cmake
cmake --build .
make install
build shared library for PyLammps
#first return to main LAMMPS directory
cd …
mkdir build-shared
cd build-shared
cmake …/cmake -DPKG_MOLECULE=yes -DLAMMPS_EXCEPTIONS=yes -DBUILD_LIB=yes -DBUILD_SHARED_LIBS=yes
make
cmake . -DPYTHON_EXECUTABLE=$(which python)
make
make install-python
create virtualenv named ‘pyenv’
virtualenv $HOME/python/pyenv
source $HOME/python/pyenv/bin/activate
(testing) make install-python
(testing) pip install matplotlib jupyter mpi4py
error message in terminal
source $HOME/python/pyenv/bin/activate
(pyenv) python3
Python 3.10.2 (main, Feb 2 2022, 06:19:27) [Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
(pyenv) import lammps
Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘lammps’