D’abord, il faut bien comprendre la différence entre un utilisateur ordinaire, un administrateur et un compte de service. Il est également crucial de comprendre l’usage de la commande sudo — n’utilisez-la pas à la légère pour contourner les restrictions d’accès.
Travaillez dans votre environnement personnel. Par « votre environnement », on entend l’espace situé dans votre dossier personnel (ou dans le dossier du compte de service). Même chose : en travaillant en tant qu’administrateur, ne créez pas de fichiers dans les zones où les utilisateurs ordinaires travaillent.
Pour Python, il faut créer un environnement virtuel. Cela s’applique aussi bien lors de la programmation dans une IDE (comme PyCharm) que dans le shell.
Lors de l’installation de modules, vous pouvez rencontrer ce problème :
pip install vllm
Réponse :
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
L’erreur signifie que vous devez utiliser un Python non système (n’utilisez pas sudo pour résoudre le problème). L’outil vous propose d’installer le paquet python3-xyz, mais je ne recommanderais pas cela. Au lieu de cela, assurez-vous que le paquet python3-full est installé sur votre système :
sudo apt install python3-full
Ensuite, créez un environnement virtuel (cela copiera les modules Python système dans le dossier que vous spécifiez, et les installations ultérieures se feront dans cet environnement) :
python3 -m venv /home/di/.venv
Ensuite, lancez Python depuis cet environnement virtuel :
# Vérification de la version
~/.venv/bin/python3 --version
Python 3.12.3
Maintenant, vous pouvez revenir à l’installation du module :
~/.venv/bin/pip install torch
~/.venv/bin/pip install vllm
Il peut y avoir une pause en raison d’erreurs, par exemple
ModuleNotFoundError: No module named 'torch'. Dans ce cas, supprimez~/.venv, mettez à jour les paquets du système, mettez à jourpipavec~/.venv/bin/pip install --upgrade pip, puis recréez~/.venv.
Si votre Python est trop récent pour VLLM (ce qui est une autre question), utilisez la documentation officielle du produit : Installation — vLLM
Attendez la fin de l’installation :
...
Downloading gguf-0.17.1-py3-none-any.whl (96 kB)
Downloading httpx-0.28.1-py3-none-any.whl (73 kB)
Downloading httpcore-1.0.9-py3-none-any.whl (78 kB)
Downloading h11-0.16.0-py3-none-any.whl (37 kB)
Downloading huggingface_hub-0.33.1-py3-none-any.whl (515 kB)
Downloading hf_xet-1.1.5-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.1/3.1 MB 3.8 MB/s eta 0:00:00
Downloading fsspec-2025.5.1-py3-none-any.whl (199 kB)
Downloading interegular-0.3.3-py37-none-any.whl (23 kB)
Downloading jinja2-3.1.6-py3-none-any.whl (134 kB)
Downloading MarkupSafe-3.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23 kB)
Downloading mistral_common-1.6.2-py3-none-any.whl (6.5 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.5/6.5 MB 3.5 MB/s eta 0:00:00
Downloading jsonschema-4.24.0-py3-none-any.whl (88 kB)
Downloading attrs-25.3.0-py3-none-any.whl (63 kB)
Downloading jsonschema_specifications-2025.4.1-py3-none-any.whl (18 kB)
Downloading openai-1.91.0-py3-none-any.whl (735 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 735.8/735.8 kB 2.9 MB/s eta 0:00:00
Downloading distro-1.9.0-py3-none-any.whl (20 kB)
Downloading jiter-0.10.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (352 kB)
Downloading typing_extensions-4.14.0-py3-none-any.whl (43 kB)
Downloading opencv_python_headless-4.11.0.86-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (50.0 MB)
━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━ 15.2/50.0 MB 2.6 MB/s eta 0:00:14