odes
odes copied to clipboard
cannot find sundials when using google colab
Thank you for this package.
I am trying to install this package on google colab but none of the methods I tried so far worked.
I am having trouble getting nix installed on google colab as it seems to install but the nix commands that I tried do not work.
Using pip install, the package seems to have trouble finding sundials. This might be linked to https://scikits-odes.readthedocs.io/en/stable/installation.html?highlight=%24SUNDIALS_INST#linking-errors but I do not understand that paragraph. What does pass the correct one via the $SUNDIALS_INST environment variable.
mean in code ?
How did you install SUNDIALS? If you have not installed it, you'll need to install it first.
Once you've installed SUNDIALS, in a bash shell, run
export SUNDIALS_INST=<path_you_installed_sundials_at>
, and then run pip.
How did you install SUNDIALS? If you have not installed it, you'll need to install it first.
Once you've installed SUNDIALS, in a bash shell, run
export SUNDIALS_INST=<path_you_installed_sundials_at>
, and then run pip.
Thank you for your very quick reply
I did the following in a google colab notebook (the ! are used to execute shell commands in one line, ----\ is a personal notation to indicate different jupyter cells (might be irrelevant), %%shell is used to consider the entire cell as a shell command
! wget https://github.com/LLNL/sundials/releases/download/v6.5.1/sundials-6.5.1.tar.gz
\----\
! mkdir sundial
\----\
! tar -xzvf sundials-6.5.1.tar.gz -C sundials
\----\
%%shell
cd sundials
mkdir build-sundials-6.5.1
cd build-sundials-6.5.1
cmake -DLAPACK_ENABLE=ON -DSUNDIALS_INDEX_SIZE=64 ../sundials-6.5.1/
make
make install
\-----\
%%shell
export SUNDIALS_INST=/usr/local
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
pip install scikits.odes
\----\
import pkg_resources
pkg_resources.get_distribution("scikits.odes").version
\----\
pip install nose
\-----\
import collections
collections.Callable = collections.abc.Callable
import scikits.odes as od; od.test()
@aragilar
just mentioning that the code above did not work as my answer did not mention that
I tried with nix
! bash <(curl -L https://nixos.org/nix/install) --daemon --yes
\----\
%%shell
source /etc/bashrc
nix-shell -p python37Packages.scikits-odes -p python37Packages.numpy --run "python3"
and got the following error
error:
… while calling the 'derivationStrict' builtin
at /builtin/derivation.nix:9:12: (source not available)
… while evaluating derivation 'shell'
whose name attribute is located at /nix/store/l6fcz7knk5y1p8zz3fn9l7ifg8jvjhpc-nixpkgs/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:303:7
… while evaluating attribute 'buildInputs' of derivation 'shell'
at /nix/store/l6fcz7knk5y1p8zz3fn9l7ifg8jvjhpc-nixpkgs/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:350:7:
349| depsHostHost = lib.elemAt (lib.elemAt dependencies 1) 0;
350| buildInputs = lib.elemAt (lib.elemAt dependencies 1) 1;
| ^
351| depsTargetTarget = lib.elemAt (lib.elemAt dependencies 2) 0;
error: undefined variable 'python37Packages'
at «string»:1:107:
1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (python37Packages.scikits-odes) (python37Packages.numpy) ]; } ""
| ^
---------------------------------------------------------------------------
CalledProcessError Traceback (most recent call last)
[<ipython-input-6-6d90f54bf14f>](https://localhost:8080/#) in <cell line: 1>()
----> 1 get_ipython().run_cell_magic('shell', '', '\nsource /etc/bashrc\n\nnix-shell -p python37Packages.scikits-odes -p python37Packages.numpy --run "python3"\n')
3 frames
[/usr/local/lib/python3.10/dist-packages/google/colab/_system_commands.py](https://localhost:8080/#) in check_returncode(self)
135 def check_returncode(self):
136 if self.returncode:
--> 137 raise subprocess.CalledProcessError(
138 returncode=self.returncode, cmd=self.args, output=self.output
139 )
CalledProcessError: Command '
source /etc/bashrc
nix-shell -p python37Packages.scikits-odes -p python37Packages.numpy --run "python3"
' returned non-zero exit status 1.