Validating Python Installation#

In the interest of identifying potentially issues quickly, below are some instructions for validating your installation and checking for issues that could cause problems down the line.

Checking for Other Python Installations#

One of the things that makes Python different from many other programs you may be accustomed to — like R or Stata — is that it’s possible to have multiple fully independent installations of Python on the same computer. Each installation of Python — also referred to as an interpreter — has its own set of installed packages. Different installations may also be different versions (e.g., 3.9 versus 3.11), or the same version.

As a result, its easy as a beginning programmer to end up in situations where your code won’t run because you don’t have a specific package installed, but then when you try to install the package, you find it won’t fix the problem because the installation of Python that’s running your code is different from the installation into which you are installing the package.

So, to help avoid problems, a good next step is to check for other Python installations and remove any that aren’t needed.

On a Mac:

In a new terminal window:

  • type which -a python and hit enter. You should only see one entry, which will be something like /Users/nick/miniforge3/bin/python, where the name that follows /Users/ is your username.

  • type which -a python3 and hit enter. You should only see two entries: /Users/nick/miniforge3/bin/python3 and /usr/bin/python3.

    • /usr/bin/python3 is a version of Python that is part of macOS. It’s ok it’s there, and you don’t want to play with it.

If you see any other entries, such as:

  • /Users/nick/miniconda3/bin/python

  • /Users/nick/anaconda3/bin/python

  • /opt/anaconda3/bin/python

  • /opt/homebrew/bin/python3

Then you have other installations of Python you want to remove. To do so:

  • If you have an installation in your user folder (e.g., /Users/nick/miniconda3/bin/python or /Users/nick/anaconda3/bin/python), then open your user folder, look for the folder called miniconda3 or anaconda3, put it in the trash and empty the trash. Delete the whole miniconda3 or anaconda3 folder.

  • If you have an installation whose path starts with /opt/ (e.g., /opt/anaconda3) open your terminal and type cd /opt; open .. That should cause a Finder window to open in which you should see anaconda3 or homebrew.

    • if you see a anaconda3 or miniconda3 folder, drag it to the trash. Your computer will ask for your password or TouchID.

    • if you see homebrew, you have two choices. If you don’t know what homebrew is or how it got there, then drag it to the trash. If you know what it is and want it there because your using it for something else, run brew uninstall python.

Then open a new terminal and re-run which -a python and which -a python3 again to doublecheck that you only have one entry under which -a python and two under which -a python3.

Let’s Check Functionality by Installing A Few Standard Packages#

If you plan to do much data science, then it also makes sense to now install a few packages to help make life easier. Doing this install is also a good way to make sure things are installed and working correctly up to this point.

To install this first set of packages, open a new terminal window and run the command:

conda install pandas matplotlib jupyter notebook

It’ll think a little, then it’ll ask you to confirm this is what you want to do. Type y and hit enter and let it rip!

Having Issues?#

These directions will hopefully address most common problems, but if you’re still having issues, please bring them to an instructor or TA!