After starting out with Python on Ubuntu Linux, I\'ve now for a good while been doing most of my sustained work on the Mac, currently Mac OS X 10.6. Unfortunately
This is an old question, but I have struggled in the past with upgrading Python and virtual environments. I have figured out how to get this to work for the stuff I do. Hopefully this will help someone.
Setup:
Mac running 10.14
Python 3.7
Various packages: Pandas, IPython, Paramiko, etc.
Python:
Just use the installer they provide at Python.org. Click on the "Download" button for macOS, download the packages and click through the installer. Done. When it comes time to upgrade to the next Python 3 version, repeat the process.
To get the Python3 interpreter on the command-line instead of the Python2 one, use python3 instead of python.
Getting Rid of Older Python3 versions
If you don't like the idea of having old Python versions hanging around, open the Applications folder and drag-and-drop the old Python3 version you don't want to the trash. DO NOT do this to the Python2 versions unless you know what you a re doing. Some of these came with the OS and will likely cause trouble if they disappear.
Installing Packages:.
@Ned Deily's suggestion to use virtual environments is a good one if you want to make installing packages easier. The virtual environment tool for Python2 is 'virtualenv'. That tool is called 'venv' in Python3.
Step 1:
Create a directory to hold all of your virtual environments. This isn't necessary, but this is how I keep track of mine. I keep two separate dirs named 'virtenvs' and 'venvs' depending on whether I'm installing a package for Python2 or Python3. For this example, we'll use Python3:
cd ~
mkdir venvs
cd venvs
Now, I name my packages after my project or after the major package I've installed. For this example, let's just call it 'project1':
venv project1
Step 2:
"Activate" the virtual environment using the following command. You'll need to to this every time you start a new terminal or session.
source ~/venvs/project1/bin/activate
Pip changes a lot, so update it
pip install --upgrade pip
Step 3:
Now you're ready to start installing packages into your new virtual environment:
pip install pandas
etc.
When you're done or you want to switch to a different virtual environment, just type:
deactivate
What's Next:
Explore the web for more info on Python virtual environments. Using this approach, I've not run into a package that required MacPorts, Anaconda, etc. There are undoubtedly packages that do. YMMV. Hopefully this approach will work for you.