I’ve just started working on a Python project in IntelliJ Idea. It uses some Python packages so I added them to /etc/nixos/configuration.nix
:
python39Packages.setuptools
python39Packages.psycopg2
python39Packages.flask_sqlalchemy
python39Packages.sqlalchemy
python39Packages.flask
and ran nixos-rebuild switch
and nix-collect-garbage
.
IntelliJ shows the packages os, flask, flask_sqlalchemy and psycopg2 as missing. It redlines them in the import
declarations.
So in IntelliJ I go to platform settings / SDKs and add a system SDK for Python 3.9. Where is it?
$ find /nix/ -name python -type f -ls
5880022 40 -r-xr-xr-x 1 root root 37912 Jan 1 1970 /nix/store/zmv5aycaa7jqsym7m8r5jf6ij85h92y1-python3-3.9.13-env/bin/python
5881530 40 -r-xr-xr-x 1 root root 37912 Jan 1 1970 /nix/store/gp38glll1sfbjk3a0sgf3gnqjn6blls9-python3-3.9.13-env/bin/python
6600857 40 -r-xr-xr-x 1 root root 37912 Jan 1 1970 /nix/store/4h9b1dl9ivzbkqxs1ix9hsqbp8gq8l82-python-2.7.18-env/bin/python
6867049 4 -r--r--r-- 1 root root 1767 Jan 1 1970 /nix/store/rwv2yf25yrwfqp9fia6hjhw9825iyfcq-bash-completion-2.11/share/bash-completion/completions/python
6867241 4 -r--r--r-- 1 root root 331 Jan 1 1970 /nix/store/rwv2yf25yrwfqp9fia6hjhw9825iyfcq-bash-completion-2.11/share/bash-completion/helpers/python
7128467 40 -r-xr-xr-x 1 root root 37912 Jan 1 1970 /nix/store/af2yihxp23l5ial6p6j5jp54h9m6xwll-python3-3.9.13-env/bin/python
7130887 40 -r-xr-xr-x 1 root root 37912 Jan 1 1970 /nix/store/54xnhsbk25a9w87z4ana80kyr4gkzg47-python3-3.9.13-env/bin/python
7282398 40 -r-xr-xr-x 1 root root 37912 Jan 1 1970 /nix/store/jxa2j7x0gxw4kjf39ipn3s4yp6m4a0d3-python3-3.9.13-env/bin/python
7373098 40 -r-xr-xr-x 1 root root 37912 Jan 1 1970 /nix/store/i6f7qkpa8z8c80swfwhigf4dqcrbzscr-python3-3.9.13-env/bin/python
I tried all six candidates in the Python SDK home path but IntelliJ still redlines the packages it says are missing.
What do I do to fix this? I tried to set up a venv but the build of psycopg2 fails with a compilation error.