From c594c0aa1449846432841f197241b71341c9504c Mon Sep 17 00:00:00 2001 From: marouenbg Date: Wed, 10 Jun 2026 17:32:11 -0400 Subject: [PATCH 1/2] Add scikit-learn to install_requires (#391) netZooPy/cobra/cobra.py imports `from sklearn.linear_model import ...`, but setup.py omitted scikit-learn from install_requires (it was only in requirements.txt). Because netZooPy/__init__.py eagerly runs `from netZooPy import cobra`, a fresh `pip install -e .` left not just COBRA but `import netZooPy` itself broken with `ModuleNotFoundError: No module named 'sklearn'`. Also show the COBRA import in the README usage example. Fixes #391 Co-Authored-By: Claude Fable 5 --- README.md | 1 + setup.py | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 8977038d..d7052321 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ Upon completion you can load netZooPy in your python code through ```python import netZooPy +from netZooPy.cobra import cobra ``` ## Conda installation diff --git a/setup.py b/setup.py index f1be2820..8a85e71f 100755 --- a/setup.py +++ b/setup.py @@ -21,6 +21,7 @@ 'igraph', 'joblib>=1.1.0', 'statsmodels>=0.12.2', + 'scikit-learn', 'click', 'tables', 'torch' From 35ac13b045c87e88bd58e6d674424f90729a5ed2 Mon Sep 17 00:00:00 2001 From: marouenbg Date: Wed, 10 Jun 2026 17:43:38 -0400 Subject: [PATCH 2/2] Revamp install docs: sync deps and add import troubleshooting (#391) - Update the dependency list to match setup.py install_requires (adds h5py, joblib, statsmodels, scikit-learn, click, tables, torch) and note that pip installs them automatically; document CuPy as the optional GPU dependency. - Recommend installing inside a virtual environment. - Expand the Troubleshooting section with the two failure modes behind issue #391: the namespace-shadowing import error (running from the clone's parent / wrong kernel) and the missing-scikit-learn error. Keeps the README minimal; troubleshooting lives in the install guide. Co-Authored-By: Claude Fable 5 --- docs/install/index.md | 75 +++++++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 17 deletions(-) diff --git a/docs/install/index.md b/docs/install/index.md index 1d9e41eb..80a0af7b 100644 --- a/docs/install/index.md +++ b/docs/install/index.md @@ -1,41 +1,82 @@ # Installation guide -You can install netZooPy through pip or through conda. Below, you will find +You can install netZooPy through pip or through conda. Below, you will find all the steps and requirements for both cases. ## PIP installation ### Requirements -- Python 3 - -In addition to the following pip packages: - -- networkx - -- numpy +netZooPy requires Python 3. `pip` installs the following dependencies +automatically, so you normally do not need to install them by hand: +- h5py - pandas - +- numpy +- networkx - matplotlib - - scipy - - python-igraph +- joblib +- statsmodels +- scikit-learn +- click +- tables (PyTables) +- torch (PyTorch) + +GPU acceleration (the `gpu` computing option in PANDA, LIONESS, PUMA and OTTER) +additionally requires [CuPy](https://cupy.dev). CuPy is **not** installed +automatically because the right build depends on your CUDA version — install +the one that matches your toolkit, e.g. `pip install cupy-cuda12x`. ### Install -- `git clone https://github.com/netZoo/netZooPy.git` +We recommend installing netZooPy inside a dedicated virtual environment so it +stays isolated from your other projects: -- `cd netZooPy` +```bash +python3 -m venv netzoo-env +source netzoo-env/bin/activate # Windows: netzoo-env\Scripts\activate +git clone https://github.com/netZoo/netZooPy.git +cd netZooPy +pip3 install -e . +``` -- `pip3 install -e .` +Then you can import netZooPy and its modules in your code: -- Then you can import netZooPy in your code through `import netZooPy` +```python +import netZooPy +from netZooPy.cobra import cobra +``` ### Troubleshooting -- To report any installation issue or function bug, please report through opening an [issue](https://github.com/netZoo/netZooPy/issues) on github. +**`import netZooPy` works but a submodule import fails** — for example +`from netZooPy.cobra import cobra` raises +`ModuleNotFoundError: No module named 'netZooPy.cobra'`, or you see +`ImportError: cannot import name 'cobra' from 'netZooPy' (unknown location)`. + +This means Python is importing the cloned *source folder* instead of the +installed package. It usually happens when: + +- you start Python (or a Jupyter / VS Code notebook kernel) from the directory + that *contains* the cloned `netZooPy` folder — the folder name then shadows + the installed package as an empty namespace package; or +- the active interpreter / kernel is not the same environment where you ran + `pip3 install -e .` (a common mismatch in VS Code and Jupyter). + +Quick check: run `python -c "import netZooPy; print(netZooPy.__file__)"`. If it +prints `None`, you are loading the empty namespace folder rather than the +package. To fix it, make sure your interpreter / notebook kernel is the +environment where netZooPy is installed, and start Python from a directory +other than the one containing the clone. + +**`ModuleNotFoundError: No module named 'sklearn'`** when importing COBRA means +scikit-learn is missing. Update to the latest netZooPy (scikit-learn is now a +declared dependency) or install it manually with `pip install scikit-learn`. + +For any other installation issue or function bug, please open an +[issue](https://github.com/netZoo/netZooPy/issues) on GitHub. ## Conda installation @@ -46,4 +87,4 @@ To install netzoopy through conda: ```bash conda install -c netzoo -c conda-forge netzoopy -``` \ No newline at end of file +```