Given an activated Python 3.6 virtualenv in somepath/venv, the following aliases resolved the various issues on a macOS Sierra where pip insisted on pointing to Apple's 2.7 Python.
alias pip='python somepath/venv/lib/python3.6/site-packages/pip/__main__.py'
This didn't work so well when I had to do sudo pip
as the root user doesn't know anything about my alias or the virtualenv, so I had to add an extra alias to handle this as well. It's a hack, but it works, and I know what it does:
alias sudopip='sudo somepath/venv/bin/python somepath/venv/lib/python3.6/site-packages/pip/__main__.py'
pip3 did not exist to start (command not found) with and which pip
would return /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/pip, the Apple Python.
Python 3.6 was installed via macports.
After activation of the 3.6 virtualenv I wanted to work with, which python
would return somepath/venv/bin/python
Somehow pip install
would do the right thing and hit my virtualenv, but pip list
would rattle off Python 2.7 packages.
For Python, this is batting way beneath my expectations in terms of beginner-friendliness.