Python and pip in NixOS

Hello,
total NixOS newbie here.

I want to install pip packages in NixOS but got several Errors.

When i want to install pip packages via terminal and pip install npyscreen I get the following error:

WARNING: You are using pip version 20.1.1; however, version 21.3.1 is available

It also said that I use python 3.8 but when I run pyhton3 it show me the Version 3.9.

My question: Why is using NixOS the older python version and how do I upgrade pip and install the packages?

Thanks and sorry for not-knowing :smiley:

1 Like

Probably the less intrusive way is to use virtual environments, for instance:

$ python3.8 -m venv example
$ source example/bin/activate
$ pip install xxx
$ echo 'xxx is now available here'
$ deactivate
$ echo 'xxx is no logner available'

Now, getting python3.8 can be done with nix-shell, nix-build, or nix-env

4 Likes

FYI the output from pip there is a warning, not an error.

You may want to read the Python section of the manual, especially this section: https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/python.section.md#how-to-consume-python-modules-using-pip-in-a-virtual-environment-like-i-am-used-to-on-other-operating-systems-how-to-consume-python-modules-using-pip-in-a-virtual-environment-like-i-am-used-to-on-other-operating-systems

2 Likes

yes this works fine. Thank you so much. I have to learn a lot about NixOS :sweat_smile:

2 Likes

thanks for the link :slight_smile: