My python3 installation cannot import modules despite apparently installing them:
$ python3
Python 3.10.6 (main, Aug 1 2022, 20:38:21) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
(same as e.g.: pandas).
I followed this wiki and integrated it into my configuration, as follows:
$ nix profile list
error: experimental Nix feature 'nix-command' is disabled; use '--extra-experimental-features nix-command' to override
The last command gives:
$ ls -l $(find "$(dirname $(which python))/.." -name site-packages)
totale 12
dr-xr-xr-x 2 root root 4096 Jan 1 1970 __pycache__
-r--r--r-- 1 root root 119 Jan 1 1970 README.txt
-r--r--r-- 1 root root 1659 Jan 1 1970 sitecustomize.py
lrwxrwxrwx 1 root root 44 Jan 1 1970 _sysconfigdata__linux_x86_64-linux-gnu.py -> ../_sysconfigdata__linux_x86_64-linux-gnu.py
I donât know if somehow having set the experimental packages declaratively on configuration.nix instead of through using nix-env may have resulted into two distict versions of pyton? But I do not know how to veryfy that.
If you were using the correct python env, there would be directories for your packages in there.
So youâre definitely not using the python from your config. The question is, what python are you using? At this point Iâm not sure how to check that, unfortunately⌠Maybe check if which python points at a non-system profile?
Using nix-env -q, to check if you installed a second instance of python with nix-env. Your configuration looks correct to me otherwise, but sharing your full config could help spot something unusual.
If that says it does not depend on /run/current-system /nix/store/sz0j8k8ljh7y8qgyfxgqb3ws11bcy4gs-python3-3.10.6 then you got in on your PATH from something else but your system profile.
I used to have vim_configurable for a while before removing it and deciding to configure vim via home-manager. Why has it remained in the system? Would it be useful (provided that it is possible) to purge the store completely and rebuild the configuration without formatting and reinstalling?
Then vim_configurable is propagating using Python to the user environment using âpropagatedUserEnvPkgsâ, something which I think should not be used because it can lead to issues likes these.
Nevermind, it is not propagating, it just depends on it. That is OK. But you still have it somehow in your PATH.
No, but a module might. Anyway, if that reference you showed is the only one, then it would seem some home-manager configuration or something else manipulating your PATH introduced it.
I made some test removing and adding packages to my configuration and I noticed that python lmodules do work in my configuration - if python3 is execuded from from the gnome builtin console. They do NOT work if is executed on terminator, which is the console I routinely use.
Has anyone got any idea about why terminator display this behaviour?
This could probably be fixed by changing the packaging. Instead of using the default wrapping, one would create a python3.withPackages and patch the shebang of terminator. That way the program is started with itâs own Python environment, but it wonât leak.
It can definitely be fixed by the packaging. Worst case scenario, you can patch it to run an âunwrappingâ script around whatever shell it runs, to clean the environment back up.