2

I've installed both pip (pip27) and pip3 (pip37) for Python.

However, MacPorts has only created one group called "pip" that can either be set to pip27, pip37 or none.

I want pip27 to be available as pip and pip37 to be available as pip3.

How can I create an additional group, so that I can easily use both pip and pip3 from the Terminal app? None of the port select subcommands seem to provide this option?

Currently, MacPorts has the following groups:

Nicolass-MacBook-Pro:Projects nlykkei$ port select --summary
Name        Selected      Options
====        ========      =======
pip         pip27         pip27 pip37 none
python      python27      python27 python27-apple python37 none
python2     none          python27 python27-apple none
python3     python37      python37 none
virtualenv  virtualenv37  virtualenv37 none
4
  • Are you just trying to run python 3.7 or python2.7?
    – Natsfan
    Feb 10, 2019 at 15:34
  • @jmh - well, I'm trying to run pip and pip3 without having to run port select --set pip pip27-pip etc.
    – Shuzheng
    Feb 10, 2019 at 17:11
  • Are you using Anaconda for your python?
    – Natsfan
    Feb 10, 2019 at 20:22
  • @jmh - I am not using that.
    – Shuzheng
    Feb 11, 2019 at 18:41

2 Answers 2

1

What you're looking for is how to create "subports". These are defined in Portfiles and unfortunately cannot be (officially) changed without maintainer intervention.

Here's an example with sub ports and its corresponding Portfile:

And here is one without:

It is possible to modify ports before they're installed with port edit <name>. It's been over 10 years since I've had to do this but you can modify a Portfile and then manually build it and that may be able to accomplish what you're asking for. See the DEVELOPER ACTIONS in man port for details.

1

pip is not part of the Macports python ports so you need to install it separately.

So for pip37

sudo port install py37-pip

This will install the correct pip and also pip_select -although the latter is not what you call.

You can then choose what pip3 does by using port select

this all shows up in port select --summary (Which I thank you for as I did not know this exists)

For modern python it is better not you use pip directly but use it as the module python runs e.g from Python docs = Installing Python Modules So no need for the separate install, python does it all.

instead of

pip3 install x

run

python3 -m pip install x

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .