This error occurs because your Python environment is externally managed, meaning the system Python installation is protected to prevent breaking critical dependencies.
Solution 1: Use a Virtual Environment (Recommended)
Either Venv or Conda.
Virtual environments ensure:
- Isolation of dependencies.
- Prevention of conflicts with the system Python packages.
Using virtual environments is the safest and most flexible way to manage Python dependencies.
Solution 2: Verify Correct Pip
Verify Youβre Using the Correct pip After activating the environment, check which pip is being used:
which pip
It should point to the pip within your conda environment, something like:
/path_to_conda_env/your_env_name/bin/pip
The problem lies in the fact that the pip being used is the system-wide pip (/usr/bin/pip) instead of the one associated with your conda environment (your_env_name). This is why youβre getting the “externally managed environment” error.
If problem doesn’t go away, recreate the environment.
conda deactivate
conda remove --name ollama_env --all
conda create --name ollama_env python=3.10
conda activate ollama_env
pip install -r requirements.txt