Última atividade 1 month ago

Fix PIP wanting you to install packages with APT

pip_apt_fix.sh Bruto
1#!/bin/bash
2
3# Define the pip config directory and file
4PIP_CONFIG_DIR="$HOME/.config/pip"
5PIP_CONFIG_FILE="$PIP_CONFIG_DIR/pip.conf"
6
7# Create the config directory if it doesn't exist
8mkdir -p "$PIP_CONFIG_DIR"
9
10# Add or update the break-system-packages option
11if grep -q "^\[install\]" "$PIP_CONFIG_FILE" 2>/dev/null; then
12 # [install] section exists; update or append the option
13 if grep -q "^break-system-packages" "$PIP_CONFIG_FILE"; then
14 sed -i 's/^break-system-packages.*/break-system-packages = true/' "$PIP_CONFIG_FILE"
15 else
16 sed -i '/^\[install\]/a break-system-packages = true' "$PIP_CONFIG_FILE"
17 fi
18else
19 # Add the [install] section and the option
20 {
21 echo "[install]"
22 echo "break-system-packages = true"
23 } >> "$PIP_CONFIG_FILE"
24fi
25
26echo "✅ pip is now configured to use --break-system-packages by default."