{"id":"4a84a1dacaa82809","repo":"pypa/pip","slug":"can-not-perform-a-user-install-user-site-pack","errorCode":null,"errorMessage":"Can not perform a '--user' install. User site-packages are not visible in this virtualenv.","messagePattern":"Can not perform a '--user' install\\. User site-packages are not visible in this virtualenv\\.","errorType":"exception","errorClass":"InstallationError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/commands/install.py","lineNumber":799,"sourceCode":"    options.\n    If use_user_site is None, the default behaviour depends on the environment,\n    which is provided by the other arguments.\n    \"\"\"\n    # In some cases (config from tox), use_user_site can be set to an integer\n    # rather than a bool, which 'use_user_site is False' wouldn't catch.\n    if (use_user_site is not None) and (not use_user_site):\n        logger.debug(\"Non-user install by explicit request\")\n        return False\n\n    # If we have been asked for a user install explicitly, check compatibility.\n    if use_user_site:\n        if prefix_path:\n            raise CommandError(\n                \"Can not combine '--user' and '--prefix' as they imply \"\n                \"different installation locations\"\n            )\n        if virtualenv_no_global():\n            raise InstallationError(\n                \"Can not perform a '--user' install. User site-packages \"\n                \"are not visible in this virtualenv.\"\n            )\n        # Catch all remaining cases which honour the site.ENABLE_USER_SITE\n        # value, such as a plain Python installation (e.g. no virtualenv).\n        if not site.ENABLE_USER_SITE:\n            raise InstallationError(\n                \"Can not perform a '--user' install. User site-packages \"\n                \"are disabled for this Python.\"\n            )\n        logger.debug(\"User install by explicit request\")\n        return True\n\n    # If we are here, user installs have not been explicitly requested/avoided\n    assert use_user_site is None\n\n    # user install incompatible with --prefix/--target\n    if prefix_path or target_dir:","sourceCodeStart":781,"sourceCodeEnd":817,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/commands/install.py#L781-L817","documentation":"Raised as InstallationError in decide_user_install() at install.py:798-802 when use_user_site is truthy and virtualenv_no_global() returns True. A virtualenv created with --no-site-packages (or the modern default that hides the system user-site) does not expose the user site-packages directory, so a --user install would be invisible and useless.","triggerScenarios":"Running 'pip install --user <pkg>' inside a virtualenv whose configuration hides the global/user site directory. virtualenv_no_global() checks pyvenv.cfg for include-system-site-packages=false combined with the interpreter being a venv.","commonSituations":"Habit of adding --user everywhere, carried into an activated venv; automation that blindly passes --user; upgrading pip itself with --user inside a venv.","solutions":["Drop --user and install directly into the active virtualenv (the normal, correct behavior inside a venv).","If you genuinely need user-site visibility, recreate the venv with --system-site-packages.","Remove 'user = true' from your pip.conf before working inside venvs."],"exampleFix":"# before\n(venv) $ pip install --user requests\n# after\n(venv) $ pip install requests","handlingStrategy":"validation","validationCode":"import sys, site\n# Detect being inside a venv that hides global/user site\nin_venv = sys.prefix != sys.base_prefix\nif in_venv and '--user' in sys.argv:\n    # virtualenv_no_global checks pyvenv.cfg; approximate by site.ENABLE_USER_SITE\n    print('WARNING: --user is not visible inside this venv; dropping --user', file=sys.stderr)\n    sys.argv = [a for a in sys.argv if a != '--user']","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not use --user inside a virtualenv — install directly into the venv.","Check sys.base_prefix != sys.prefix to detect a venv before passing --user.","Remove 'user = true' from pip.conf when working primarily in venvs."],"tags":["pip","install","virtualenv","user-site"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}