DEV Community

Chan
Chan

Posted on • Edited on

1

Error: externally-managed-environment on python package installation

Symptoms

I attempted to install a Python package using this command.

pip3 install [package-name]
Enter fullscreen mode Exit fullscreen mode

And then this error was thrown.

Error message Summary

Error message description

Description

  • Two types of Python are used in a single MacOS machine - User-specific and System-wide packages.
  • System-wide packages are shared by all the users, and even system package managers like apt. Installing user-specific packages as system-wide packages is very dangerous because it can conflict with system package managers if they run some Python scripts.

Solution

  1. Create ~/.config/pip/pip.conf and type this script.

    [install]
    break-system-packages = true
    user = true
    
  2. Install pipenv to manage dependencies per project. The pip.conf file lets the command run with --break-system-packages and --user options. Otherwise, pipenv can't install some dependencies since the python packages require a certain python version.

    pip3 install pipenv
    which python3.13
    pipenv --python /opt/homebrew/bin/python3.13(directory of python)
    
  3. If you're using zsh, add the directory of python to the PATH. Make sure the version is set explictly! Otherwise, pipenv command won't be found.

    export PATH="$HOME/Library/Python/3.13/bin:$PATH" # This loads 
    python
    
  4. Run a file with the all project dependencies in a virtual environment

    pipenv run python [file-name] .py
    
  5. Otherwise, you could run up a virtual environment instance and run the python file.

    pipenv shell
    python [file-name].py
    

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more