{"id":"4c77f3dc2a0b5ab6","repo":"pypa/pip","slug":"can-not-perform-a-user-install-user-site-pack-4c77f3","errorCode":null,"errorMessage":"Can not perform a '--user' install. User site-packages are disabled for this Python.","messagePattern":"Can not perform a '--user' install\\. User site-packages are disabled for this Python\\.","errorType":"exception","errorClass":"InstallationError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/commands/install.py","lineNumber":806,"sourceCode":"        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:\n        logger.debug(\"Non-user install due to --prefix or --target option\")\n        return False\n\n    # If user installs are not enabled, choose a non-user install\n    if not site.ENABLE_USER_SITE:\n        logger.debug(\"Non-user install because user site-packages disabled\")\n        return False","sourceCodeStart":788,"sourceCodeEnd":824,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/commands/install.py#L788-L824","documentation":"Raised as InstallationError in decide_user_install() at install.py:805-809 when use_user_site is truthy and site.ENABLE_USER_SITE is False. The running Python was built or configured to disable the user site-packages directory entirely (e.g. python started with -s or PYTHONNOUSERSITE set), so a --user install cannot place files anywhere visible.","triggerScenarios":"The interpreter has user-site disabled — PYTHONNOUSERSITE=1 in the environment, python invoked with -s, or a distro build of Python that defaults site.ENABLE_USER_SITE to False. Combine that with an explicit --user install.","commonSituations":"Distro-managed Python (some RHEL/Debian setups), container images that export PYTHONNOUSERSITE, or wrapper scripts that add -s. The user copies a --user command from a tutorial without realizing their interpreter forbids user-site.","solutions":["Remove --user and install to the system or virtualenv site-packages (use a venv or --break-system-packages / --target if needed).","Unset PYTHONNOUSERSITE and avoid launching python with -s, then retry --user.","Install into a virtualenv instead, which sidesteps the user-site flag entirely."],"exampleFix":"# before\n$ export PYTHONNOUSERSITE=1\n$ pip install --user requests  # fails\n# after\n$ unset PYTHONNOUSERSITE\n$ pip install --user requests","handlingStrategy":"validation","validationCode":"import os, site, sys\nif os.environ.get('PYTHONNOUSERSITE') or not site.ENABLE_USER_SITE:\n    if '--user' in sys.argv:\n        print('ERROR: user-site is disabled in this interpreter; cannot use --user', file=sys.stderr)\n        sys.exit(2)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check site.ENABLE_USER_SITE before passing --user.","Unset PYTHONNOUSERSITE and avoid python -s if you need user-site installs.","Prefer virtualenvs over --user installs in managed environments."],"tags":["pip","install","user-site","environment","pythonnousersite"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}