Issue installing global python packages

I am trying to globally install some packages for all users using

sudo -E pip install packagename

While the packages seem to be available for all the users, some of the internal dependencies of the packages are missing, but only for other users, not for the admin that installed the packages.

Eg custom packages uses pydantic uses annotated-types, which cannot be found. The missing package can be installed by the user, but then another dependency is missing.

How do I get the packages installed correctly?

Does pip list and/or pip freeze show the correct list of packages? Can you show us the output of running pip install packagename? The output should show all the dependencies that are found or that will be installed.

1 Like

pip list shows more packages for the admin that installed the packages, pip list for another user is missing the missing dependencies. The missing dependencies (eg annotated-types) are not listed in the output.


Requirement already satisfied: custom_package in /opt/tljh/user/lib/python3.10/site-packages (0.6.0)
Requirement already satisfied: another_custom_package in /opt/tljh/user/lib/python3.10/site-packages (from custom_package) (0.6.0)
Requirement already satisfied: click>=8.1.7 in /opt/tljh/user/lib/python3.10/site-packages (from custom_package) (8.1.7)
Requirement already satisfied: pydantic>=2.7.1 in /opt/tljh/user/lib/python3.10/site-packages (from custom_package) (2.8.2)
Requirement already satisfied: requests>=2.31.0 in /opt/tljh/user/lib/python3.10/site-packages (from custom_package) (2.32.3)
Requirement already satisfied: gql>=3.5.0 in /opt/tljh/user/lib/python3.10/site-packages (from gql[requests]>=3.5.0->custom_package) (3.5.0)
Requirement already satisfied: pyjwt>=2.8.0 in /opt/tljh/user/lib/python3.10/site-packages (from custom_package) (2.8.0)
Requirement already satisfied: prettytable>=3.10.0 in /opt/tljh/user/lib/python3.10/site-packages (from custom_package) (3.10.2)
Requirement already satisfied: tenacity>=8.2.3 in /opt/tljh/user/lib/python3.10/site-packages (from custom_package) (8.5.0)
Requirement already satisfied: platformdirs>=4.2.1 in /opt/tljh/user/lib/python3.10/site-packages (from custom_package) (4.2.2)
Requirement already satisfied: pydantic-settings>=2.2.1 in /opt/tljh/user/lib/python3.10/site-packages (from custom_package) (2.3.4)
Requirement already satisfied: graphql-core<3.3,>=3.2 in /home/admin_username/.local/lib/python3.10/site-packages (from gql>=3.5.0->gql[requests]>=3.5.0->custom_package) (3.2.3)
Requirement already satisfied: yarl<2.0,>=1.6 in /home/admin_username/.local/lib/python3.10/site-packages (from gql>=3.5.0->gql[requests]>=3.5.0->custom_package) (1.9.4)
Requirement already satisfied: backoff<3.0,>=1.11.1 in /home/admin_username/.local/lib/python3.10/site-packages (from gql>=3.5.0->gql[requests]>=3.5.0->custom_package) (2.2.1)
Requirement already satisfied: anyio<5,>=3.0 in /opt/tljh/user/lib/python3.10/site-packages (from gql>=3.5.0->gql[requests]>=3.5.0->custom_package) (4.2.0)
Requirement already satisfied: requests-toolbelt<2,>=1.0.0 in /opt/tljh/user/lib/python3.10/site-packages (from gql[requests]>=3.5.0->custom_package) (1.0.0)
Requirement already satisfied: wcwidth in /opt/tljh/user/lib/python3.10/site-packages (from prettytable>=3.10.0->custom_package) (0.2.12)
Requirement already satisfied: annotated-types>=0.4.0 in /home/admin_username/.local/lib/python3.10/site-packages (from pydantic>=2.7.1->custom_package) (0.6.0)
Requirement already satisfied: pydantic-core==2.20.1 in /opt/tljh/user/lib/python3.10/site-packages (from pydantic>=2.7.1->custom_package) (2.20.1)
Requirement already satisfied: typing-extensions>=4.6.1 in /opt/tljh/user/lib/python3.10/site-packages (from pydantic>=2.7.1->custom_package) (4.9.0)
Requirement already satisfied: charset-normalizer<4,>=2 in /opt/tljh/user/lib/python3.10/site-packages (from requests>=2.31.0->custom_package) (2.0.12)
Requirement already satisfied: idna<4,>=2.5 in /opt/tljh/user/lib/python3.10/site-packages (from requests>=2.31.0->custom_package) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in /opt/tljh/user/lib/python3.10/site-packages (from requests>=2.31.0->custom_package) (1.26.15)
Requirement already satisfied: certifi>=2017.4.17 in /opt/tljh/user/lib/python3.10/site-packages (from requests>=2.31.0->custom_package) (2022.12.7)
Requirement already satisfied: sniffio>=1.1 in /opt/tljh/user/lib/python3.10/site-packages (from anyio<5,>=3.0->gql>=3.5.0->gql[requests]>=3.5.0->custom_package) (1.3.0)
Requirement already satisfied: exceptiongroup>=1.0.2 in /opt/tljh/user/lib/python3.10/site-packages (from anyio<5,>=3.0->gql>=3.5.0->gql[requests]>=3.5.0->custom_package) (1.2.0)
Requirement already satisfied: python-dotenv>=0.21.0 in /home/admin_username/.local/lib/python3.10/site-packages (from pydantic-settings>=2.2.1->another_custom_package->custom_package) (1.0.0)
Requirement already satisfied: multidict>=4.0 in /home/admin_username/.local/lib/python3.10/site-packages (from yarl<2.0,>=1.6->gql>=3.5.0->gql[requests]>=3.5.0->custom_package) (6.0.4)

This bit is probably relevant:

Some packages are installed with --user, which would be considered satisfying dependencies for later installs in the shared environment.

Setting PYTHONNOUSERSITE=1 environment variable should stop considering --user-installed packages, I think:

PYTHONNOUSERSITE=1 pip install packagename

Or you can add it to the default environment (which would mean --user-installed packages wouldn’t be importable for users, if that’s what you want)

3 Likes

It worked and now the dependencies are working for all users.

Thank you so much for your help!

1 Like