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!
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.