📚 Dependencies

kNNpy makes use of the following packages:

These need to be installed before using the package, preferably in a fresh virtual environment (see instructions below).


🛠 Installation

🖥️ macOS

Change to your preferred installation directory.

📥 Clone this repository

git clone https://github.com/vikhyat108/kNNpy.git
cd kNNpy

🏃‍♂️ Run these commands

python3 -m venv Setup/kNNpy_env
source Setup/kNNpy_env/bin/activate
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install llvm
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"
brew install libomp
export LDFLAGS="-L/opt/homebrew/opt/libomp/lib"
export CPPFLAGS="-I/opt/homebrew/opt/libomp/include"
brew install hdf5
pip install --upgrade pip
pip install "setuptools<82"
pip install -r Setup/requirements_no_Pylians.txt
git clone https://github.com/franciscovillaescusa/Pylians3.git
cd Pylians3
sed -i '' 's/-fopenmp//g' setup.py
python3 -m pip install .

⚠️ Warning: these installation steps have only been tested on macOS-14, 15 and 26 using python 3.11, 3.12, 3.13 and 3.14. Kindly raise an issue if you run into problems installing on other versions.


🐧 Linux

Change to your preferred installation directory.

📥 Clone this repository

git clone https://github.com/vikhyat108/kNNpy.git
cd kNNpy

🏃‍♂️ Run these commands

sudo apt-get update
sudo apt-get install -y build-essential libomp-dev python3-dev
python3 -m venv Setup/kNNpy_env
source Setup/kNNpy_env/bin/activate
pip install --upgrade pip
pip install "setuptools<82"
pip install -r Setup/requirements_no_Pylians.txt
git clone https://github.com/franciscovillaescusa/Pylians3.git
cd Pylians3
python -m pip install .

⚠️ Warning: these installation steps have only been tested on ubuntu-22.04, 24.04 and 26.04 LTS using python 3.11, 3.12, 3.13 and 3.14. Kindly raise an issue if you run into problems installing on other versions.


🪟 Windows

Unfortunately, kNNpy is currently not supported on Windows. Future support may be added in later releases.


🧭 Set your PYTHONPATH

Export the path to the installed repository to your Python path:

export PYTHONPATH="${PYTHONPATH}:/path/to/installation/directory/kNNpy/"

✅ Test the installation

To check if kNNpy is successfully installed and ready to use, run the following command:

cd /path/to/installation/directory/
cd kNNpy/Tests/
python3 import_all_modules.py

If no error message is returned, the installation is succesful.


▶️ Usage

Change to your working directory:

cd /my/working/directory

Activate your virtual environment:

source /path/to/installation/directory/kNNpy/Setup/kNNpy_env/bin/activate

Set the PYTHONPATH (if not already done) and in your Python scripts or notebooks, you can now:

import kNNpy