Recommendation for installing Python modules: pip or Macports

Joshua Root jmr at macports.org
Wed Dec 7 02:10:27 UTC 2022


Tom Gederberg wrote:
> It appears that you can either install Python modules (py310-matplotlib, py310-numpy, etc) either directly from MacPorts or you can install pip (for example py30-pip) with MacPorts and then use pip to install the modules.
>
> Is there a recommendation on which way to go?

There are a couple of important points here.

1. Don't use pip (or anything else) to install python modules into the same prefix that MacPorts uses. MacPorts won't know about them and you will get file conflicts. You can use the --user option to install into your home directory, or as has already been mentioned, the more scalable approach is to use virtualenv/venv and install whatever you want inside the isolated container.

2. MacPorts doesn't have all the modules on PyPI by a long shot. The modules that are provided as ports are usually there because either they depend on some non-python-module thing that is in MacPorts (and usually pip won't be able to install such dependencies), or something else in MacPorts depends on them.

So it depends what you're doing. You can combine the two to some extent by using e.g. virtualenv's --system-site-packages option.

- Josh



More information about the macports-users mailing list