ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv

avatar
Borislav Hadzhiev

Last updated: Apr 10, 2024
2 min

banner

# ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.

The error "Can not perform a '--user' install. User site-packages are not visible in this virtualenv" occurs for multiple reasons:

  1. Running the pip install command with the --user option with a virtual environment active.
  2. Trying to install a module in VSCode (e.g. pylint) with a virtual environment active.
  3. Having the user property set to true in your pip.conf file.

error can not perform user instal

To solve the error:

  1. Open your venv folder.
  2. Click on the pyvenv.cfg file.
  3. Set the include-system-site-packages property to true.
  4. Save the file.
  5. Rerun the pip install command.

include system site packages

You might have to reactivate the virtual environment after setting include-system-site-packages to true.

shell
# ๐Ÿ‘‡๏ธ Deactivate deactivate # ๐Ÿ‘‡๏ธ Activate on macOS and Linux source venv/bin/activate # ๐Ÿ‘‡๏ธ Activate on Windows (cmd.exe) venv\Scripts\activate.bat # ๐Ÿ‘‡๏ธ Activate on Windows (PowerShell) venv\Scripts\Activate.ps1
You should be able to install the module after you've set the include-system-site-packages property to true in your pyvenv.cfg file.

If you got the error when explicitly running a pip install command with the --user option, you can:

  • deactivate the virtual environment before running the command.
  • use the sudo prefix to install the module globally (macOS or Linux)
shell
# ๐Ÿ‘‡๏ธ Deactivate the virtual environment deactivate # ๐Ÿ‘‡๏ธ Install the module with the `--user` option pip install requests --user pip3 install requests --user python -m pip install requests --user python3 -m pip install requests --user py -m pip install requests --user

deactivate and install with user flag

# Prefixing the command with sudo to install the package globally

Alternatively, you can prefix the command with sudo on macOS or Linux to install the module globally.

shell
sudo pip install requests --user sudo pip3 install requests --user sudo python -m pip install requests --user sudo python3 -m pip install requests --user
Another common cause of the error is having set the user variable to true in your global pip.conf file.

The location of the pip.conf file is going to differ depending on your operating system.

You can check this section of the docs to view the locations of pip.conf on the different operating systems.

If you still get the error even when installing packages without the --user option, make sure you haven't set the user variable to true in your pip.conf file.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2025 Borislav Hadzhiev