Skip to content

Commit 4aa8431

Browse files
authored
Docs: Update installation guide for PEP 668 compatibility (#6495)
Modern Linux distributions (Ubuntu 24.04+, Fedora 38+) enforce PEP 668 which prevents 'pip install --user'. Updated the installation docs to: - Add new recommended approach: isolated venv for pipenv - Document PIPENV_IGNORE_VIRTUALENVS=1 for proper project isolation - Add per-project bootstrap instructions for CI/CD - Mark legacy --user installation with warning about PEP 668 - Update best practices and next steps sections - Mention 'pipenv activate' as an alternative to 'pipenv shell' Fixes #6264
1 parent 618e565 commit 4aa8431

1 file changed

Lines changed: 47 additions & 7 deletions

File tree

docs/installation.md

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,57 @@ If pip is not installed, you can install it following the [pip installation guid
3030

3131
## Installation Methods
3232

33-
### Recommended: User Installation
33+
### Recommended: Isolated Virtual Environment Installation
3434

35-
The recommended approach is to install Pipenv for your user account. This avoids permission issues and prevents conflicts with system packages:
35+
Modern Python installations (Python 3.11+ on recent Linux distributions like Ubuntu 24.04, Fedora 38+) enforce [PEP 668](https://peps.python.org/pep-0668/), which prevents installing packages with `pip install --user`. The recommended approach is to install Pipenv in its own isolated virtual environment.
36+
37+
#### Option 1: Dedicated Pipenv Virtual Environment (Recommended)
38+
39+
Create a dedicated virtual environment for pipenv that auto-activates in your shell:
40+
41+
```bash
42+
# Create a dedicated venv for pipenv
43+
$ python3 -m venv ~/.pipenv-venv
44+
45+
# Install pipenv in this venv
46+
$ ~/.pipenv-venv/bin/pip install pipenv
47+
48+
# Add to your shell configuration (~/.bashrc, ~/.zshrc, or ~/.profile)
49+
$ echo 'export PIPENV_IGNORE_VIRTUALENVS=1' >> ~/.bashrc
50+
$ echo 'export PATH="$HOME/.pipenv-venv/bin:$PATH"' >> ~/.bashrc
51+
52+
# Reload your shell
53+
$ source ~/.bashrc
54+
```
55+
56+
The `PIPENV_IGNORE_VIRTUALENVS=1` setting ensures pipenv still creates and manages separate virtual environments for your projects.
57+
58+
#### Option 2: Per-Project Bootstrap
59+
60+
For CI/CD or when you want pipenv isolated per-project:
61+
62+
```bash
63+
$ python3 -m venv .venv
64+
$ source .venv/bin/activate # On Windows: .venv\Scripts\activate
65+
$ pip install pipenv
66+
$ pipenv install
67+
```
68+
69+
### Legacy: User Installation
70+
71+
On older systems that don't enforce PEP 668, you can still use user installation:
3672

3773
```bash
3874
$ pip install --user pipenv
3975
```
4076

41-
This installs Pipenv in your user site-packages directory.
77+
```{warning}
78+
This method no longer works on modern Linux distributions (Ubuntu 24.04+, Fedora 38+) due to PEP 668. Use the isolated virtual environment approach above instead.
79+
```
4280

4381
### Adding Pipenv to PATH
4482

45-
After installing with `--user`, you may need to add the user site-packages binary directory to your PATH.
83+
If you used the legacy `--user` installation, you may need to add the user site-packages binary directory to your PATH.
4684

4785
#### On Linux and macOS
4886

@@ -327,11 +365,11 @@ If pip is not found:
327365

328366
## Best Practices
329367

330-
1. **Use user installation** (`--user`) to avoid permission issues and system conflicts.
368+
1. **Use isolated virtual environment installation** on modern systems to avoid PEP 668 restrictions.
331369

332370
2. **Keep Pipenv updated** to benefit from the latest features and bug fixes.
333371

334-
3. **Consider pipx** for a cleaner, isolated installation if you use multiple Python command-line tools.
372+
3. **Set `PIPENV_IGNORE_VIRTUALENVS=1`** if you install pipenv in a dedicated venv, so it still manages project-specific environments.
335373

336374
4. **Add Pipenv to your project's development setup instructions** to ensure all developers use the same environment.
337375

@@ -343,7 +381,9 @@ Now that you have Pipenv installed, you can:
343381

344382
1. Create a new project: `pipenv --python 3.10`
345383
2. Install packages: `pipenv install requests`
346-
3. Activate the environment: `pipenv shell`
384+
3. Activate the environment:
385+
- Spawn a subshell: `pipenv shell`
386+
- Or activate in current shell: `eval $(pipenv activate)`
347387
4. Run commands: `pipenv run python script.py`
348388

349389
For more detailed usage instructions, see the [Quick Start Guide](quick_start.md) and [Commands Reference](commands.md).

0 commit comments

Comments
 (0)