Fix COBRA install: add scikit-learn dependency + revamp install docs (#391)#392
Open
marouenbg wants to merge 2 commits into
Open
Fix COBRA install: add scikit-learn dependency + revamp install docs (#391)#392marouenbg wants to merge 2 commits into
marouenbg wants to merge 2 commits into
Conversation
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 netZoo#391 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
090bd20 to
c594c0a
Compare
…#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 netZoo#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 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #391.
Problem
A user following the documented install (
git clone→cd netZooPy→pip3 install -e .) could not run COBRA.netZooPy/cobra/cobra.pyimportsfrom sklearn.linear_model import LinearRegression, Lasso, butsetup.pydid not listscikit-learnininstall_requires(it was only inrequirements.txt). BecausenetZooPy/__init__.pyeagerly runsfrom netZooPy import cobra, a cleanpip install -e .leftimport netZooPyitself broken withModuleNotFoundError: No module named 'sklearn', not just COBRA.Separately, the reporter's
No module named 'netZooPy.cobra'/(unknown location)errors come from an environment pitfall: running Python from the clone's parent directory (or a Jupyter/VS Code kernel that isn't the install env) makes the clonednetZooPyfolder resolve as an empty namespace package that shadows the installed one.Changes
scikit-learntoinstall_requires(the substantive fix).from netZooPy.cobra import cobrato the usage example.setup.py(was missing h5py, joblib, statsmodels, scikit-learn, click, tables, torch) and note pip installs them automatically; document CuPy as the optional GPU dependency;Troubleshooting content lives in the install guide (where users look) rather than the README.
Verification
python -m venv+pip install -e .now auto-installs scikit-learn;import netZooPyandfrom netZooPy.cobra import cobraboth succeed;cobra()runs innnlsandMLEmodes.tests/test_cobra.pypasses.scikit-learnwas the only undeclared hard dependency.cupyis correctly optional (lazy, GPU-only);patsyis guaranteed viastatsmodels.🤖 Generated with Claude Code