Apple - Using pip vs. MacPorts for installing Python packages
You should use pip
because it's the Python-native tool for managing package installations but you shouldn't pip-install things into your base Python installation. It can be a mess to have to sort out fixed version dependencies between multiple software repositories if you're pip-installing everything into your base Python installation on your machine.
Instead, you should pip-install virtualenv and then use it to manage different, virtual Python installations and all the associated pip-installed packages packages for each virtual environment.
This allows you to switch from working with, say, beautifulsoup
1.x in one software repository to beautifulsoup
2.x in another repository without having to wade through dependency management hell.
They can be used concurrently, and there should be no issue between mixing the two (with one kinda big caveat and a gotcha...)
The Caveat
The caveat is that macports/homebrew and pip will have no awareness of each has installed vs the other.
So, for example, lets say you install python 3.6 on your Mac. You want nltk
, which is not technically available for that version on Macports, but it is on pip. So you install on pip. Two months later, you see its installed on Macports and choose to install it. Now you have two different versions of nltk
on your machine, so caveat emptor.
The Gotcha
If you do use pip with Macports, you need to make sure that it's the pip that is installed through Macports and associated with that python version. So, for example, you will see a py35-pip, py36-pip, etc.
Once you install the proper pip, you use Macports's select
command to make sure that it's activated with the appropriate version of python:
sudo port select