1

Starting a nix-shell as follows

nix-shell -p python39Packages.ipython python39Packages.ortools --run ipython

Followed by

 import ortools

results in

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-0c521df57bb5> in <module>
----> 1 import ortools

ModuleNotFoundError: No module named 'ortools'

Any advice on how to approach this appreciated!

dejakaymac
  • 23
  • 3
  • - Is the package you are searching for available in the nixpkgs ? - you can check here https://search.nixos.org/packages - are you using the correct version of nixpkgs? – cstml Jul 23 '21 at 13:30

1 Answers1

0

This is usually the case if nix does not symlink the Python packages (the site-packages). Here, you need to combine the required Python packages using this command:

nix-shell -p "python39.withPackages(ps: with ps; [ipython ortools])" --run ipython

Then, you will be able to easily import ortools. Spawning a shell like that has the added bonus that it usually makes the command easier to read.

FabianGD
  • 186
  • 7