{"record":{"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/f399c3718970b1b0e2478dac5296eb62679a9b86/src/pip/_internal/commands/install.py#L781-L817","documentation":"Raised by `pip install --user` inside a virtualenv that was created without global site-packages visibility. decide_user_install at install.py:798 calls virtualenv_no_global(); if the venv does not include the user site directory in its sys.path, a --user install would place files Python cannot see, so pip refuses with an InstallationError.","triggerScenarios":"Inside a virtualenv created without --system-site-packages (the default), running `pip install --user <pkg>` trips virtualenv_no_global()==True at install.py:798.","commonSituations":"Scripts or wrappers that always pass --user (carried over from system-Python usage), or users who habitually use --user and forget it is incompatible with isolated venvs.","solutions":["Drop --user inside the venv: `pip install <pkg>` installs into the venv's site-packages.","If you need --user to reach a system Python, deactivate the venv first.","Recreate the venv with `python -m venv --system-site-packages` if user-site visibility is genuinely required (note security/isolation trade-offs)."],"exampleFix":"// before\n# inside a venv\npip install --user numpy\n// after\npip install numpy","handlingStrategy":"validation","validationCode":"# Detect a no-global venv before attempting --user install\nimport sys, site, os\n\ndef user_install_allowed():\n    # Heuristic: in a venv, user site must be on sys.path to be visible\n    if hasattr(sys, \"prefix\") and sys.prefix != sys.base_prefix:\n        user_site = site.getusersitepackages()\n        if user_site not in sys.path:\n            raise EnvironmentError(\"--user install not visible in this venv; recreate with --system-site-packages or drop --user\")\n    return True\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Inside a venv, omit --user and install into the venv directly.","If user-site visibility is required, create the venv with --system-site-packages.","Deactivate the venv to install into the system user site."],"tags":["cli","pip-install","virtualenv","user-site","environment","usage-error"],"backgroundTag":null,"analyzedSha":"f399c3718970b1b0e2478dac5296eb62679a9b86","analyzedAt":"2026-08-08T23:01:42.227Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}