Skip to content Skip to sidebar Skip to footer

Why My Pip Installations Requires Python -m Install --user?

I am running this inside a virtual environment. When I type: pip install django I get: ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission den

Solution 1:

Let's break the two statements you added to your first command: python -m install --user django

  • python -m: Allows modules to be located using the Python module namespace for execution as scripts. The motivating examples were standard library modules such as pdb and profile. See PEP 338

  • --user : By default pip installs Python packages to system directories which requires root privileges, to avoid using sudo pip install (which is not recommended by the way) use this flag to make pip install packages in your home directory instead, which doesn't require any special privileges.

As a side note, if you have multiple versions of Python installed, keeping track of which Python version version pip is bound to can be a PITA, hence python -m in this case you're sure that it's the pip bound to the Python called which will be executed.

Solution 2:

This is because you are trying to install the package to a system folder which you don't have permissions to write to. And the option --user allows to install it to user folder, where you do have rights (https://github.com/googlesamples/assistant-sdk-python/issues/236).

Solution 3:

The error basically states that you do not have permissions to write files to your machine, So ff you are a root user(or admin) you can always install python packages with

sudo pip install django

Or

pip install --user django

--user makes pip install packages in your home directory instead, which doesn't require any special privileges.

Post a Comment for "Why My Pip Installations Requires Python -m Install --user?"