tweag / jupyenv

Declarative and reproducible Jupyter environments - powered by Nix
https://jupyenv.io/
MIT License
671 stars 136 forks source link

[Question]: How to install latest python packages ? #545

Open alienzj opened 2 months ago

alienzj commented 2 months ago

Current Behavior

{pkgs, ...}: {
  kernel.python.bioenv = {
    enable = true;
    python = "python311";
    displayName = "Bioenv python";
    extraPackages = ps: [
      ps.pandas
      ps.numpy
      ps.seaborn
      ps.matplotlib
      ps.scipy
      ps.scikit-learn
      ps.lightgbm
      ps.xgboost
      ps.statsmodels
    ];
  };
}

For example, nix will help to install package pandas v1.5.2.

Expected Behavior

I want to install pandas v2.2.2.

Steps To Reproduce

git clone https://github.com/alienzj/jupyenvrc
cd jupyenvrc
nix run

OS

- system: `"x86_64-linux"`
- host os: `Linux 6.10.11, NixOS, 24.05 (Uakari), 24.05.20240920.944b2ae`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.18.5`
- channels(root): `"nixos, nixos-hardware"`
- nixpkgs: `/nix/store/mvz96grv31nxq69ldw5a5pn2qh1s6ca6-source`

Version

https://github.com/tweag/jupyenv/blob/main/template/flake.nix

Additional Context

After checking https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=pandas, the latest version of pandas is v2.2.2.

Relevant log output

No response

anpin commented 1 week ago

@alienzj your repository link is broken image

anpin commented 1 week ago

@alienzj were you able to find a solution?

I see you have two repositories, one of them is fork of this repo and another seems to be the reproduction you were referring to earlier, with a slightly different url https://github.com/alienzj/.jupyenvrc

If I run your repro I first get a wrong input since it is pointed at a local folder https://github.com/alienzj/.jupyenvrc/blob/058891cfdcb1c6c18570f1c03997441b60ccbadd/flake.nix#L10 If I change input to jupyenv.url = "github:alienzj/jupyenv?ref=dev"; I get

> nix run
warning: Git tree '/home/a/projects/.jupyenvrc' is dirty
error: unable to execute '/nix/store/968mfd3g4whnxgavzaspaqnyv97smjw0-wrapper-chmod-python3-3.11.10-env/bin/jupyter-lab': No such file or directory
> nix build
> ls result/bin/
2to3       idle3.11     jupyter-execute     jupyter-run           pydoc3         python3
2to3-3.11  jsonpointer  jupyter-kernel      jupyter-troubleshoot  pydoc3.11      python3-config
idle       jsonschema   jupyter-kernelspec  jupyter-trust         python         python3.11
idle3      jupyter      jupyter-migrate     pydoc                 python-config  python3.11-config

Current main branch of this repo looks like this:

> nix build .\#jupyterlab-kernel-example-python-science
> ls result/bin/
2to3                      jupyter-events                      jupyter-nbconvert        pygmentize
2to3-3.10                 jupyter-execute                     jupyter-nbextension      pyjson5
idle                      jupyter-fileid                      jupyter-notebook         python
idle3                     jupyter-kernel                      jupyter-run              python-config
idle3.10                  jupyter-kernelspec                  jupyter-server           python3
ipython                   jupyter-lab                         jupyter-serverextension  python3-config
ipython3                  jupyter-labextension                jupyter-troubleshoot     python3.10
jlpm                      jupyter-labhub                      jupyter-trust            python3.10-config
jsonpointer               jupyter-migrate                     normalizer               send2trash
jsonschema                jupyter-nbclassic                   pybabel                  wsdump
jupyter                   jupyter-nbclassic-bundlerextension  pydoc
jupyter-bundlerextension  jupyter-nbclassic-extension         pydoc3
jupyter-dejavu            jupyter-nbclassic-serverextension   pydoc3.10
anpin commented 1 week ago

ok I figured it out https://github.com/anpin/jupyenv/tree/dev jupyterlab should be under [tool.poetry.dev-dependencies] not [tool.poetry.dependencies]

diff --git a/pyproject.toml b/pyproject.toml
index 2dbd78ac..1980b4ea 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -6,10 +6,10 @@ authors = []

 [tool.poetry.dependencies]
 python = "^3.12"
-jupyterlab = "4.3.1"

 [tool.poetry.dev-dependencies]
 testbook = "*"
+jupyterlab = "4.3.1"

 [build-system]
 requires = ["poetry-core"]
alienzj commented 6 days ago

@anpin Thanks.

Yes, my current repository is set to https://github.com/alienzj/.jupyenvrc.

I will follow your suggestions soon.