Installation location for python code, tools, etc.

Joshua Root jmr at
Sun Jan 2 22:17:52 UTC 2022

> I'm not very experienced with Python, yet, but with regard to MacPorts,
> I'm trying to understand why when I do a pip3 install, or a direct
> install from a project tree ie: "python install" the tool(s)
> end up in this directory instead of /opt/local/bin|sbin etc:
> /opt/local/Library/Frameworks/Python.framework/Versions/3.9/bin/

Python is typically built as a framework on macOS, so that's where the 
modules go. See 

% python3.9
Python 3.9.9 (main, Nov 16 2021, 17:57:38)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import sys
 >>> sys.prefix

Pip has a number of options controlling where things are installed: 

I strongly recommend not installing modules into the MacPorts prefix 
with pip (or manually), because modules installed in other ways will 
conflict with modules installed by MacPorts. Install in a venv, or use 
pip's --user option or some completely separate prefix.

- Josh

More information about the macports-users mailing list