A Minimalist VPython Setup with Miniconda (Updated Monday, August 23, 2021)

I’ve updated this post to reflect one very important change to the install process under macOS 10.15 (Catalina) and one important caution. I’ve also numbered the steps for future reference.

I’ve been using a full Anaconda distribution for over a year and it takes up about 4GB of disk space on my MacBook Air, which has a 128GB drive. The only thing I use Anaconda for is VPython in Jupyter notebooks and I wanted to recover some disk space so I decided to switch to a miniconda installation. The process of removing Anaconda and installing miniconda is simple, but requires using Terminal, and there are quite a few steps. I will document the process here, assuming you already have a full Anaconda installed and that you want to completely wipe it out and start over like I did. I also assume a Mac environment.

  1. If you have an icon for Anaconda Navigator in your Dock, remove it (I’m assuming you know how to do that.).
  2. Download the miniconda installation script from this page and stick it somewhere. I left it in my Downloads folder for no really good reason. It’s a bash script and you’ll need it later. CAUTION: There is also a binary installer package (.pkg) available. I tested this installer, and it created a folder named opt in my home folder and under that created the miniconda3 folder. I don’t see the point in doing this, so I deleted ~/opt/miniconda3 and used the bash script installer instead. It creates the miniconda3 folder directly under my home directory (e.g. ~/miniconda3) which is the way Anaconda is set up on my MacBook Pro and is the structure I’ve always used.
  3. Open a Terminal. Install the anaconda-clean package by issuing conda install anaconda-clean <enter>.
  4. Issue anaconda-clean <enter>. This command will clean your home directory of all the “dot” configuration folders set up by Anaconda packages. You will be asked to confirm the deletion of each one individually. THIS STEP AND THE NEXT ONE WILL WIPE OUT ALL OF YOUR EXISTING PACKAGE INSTALLATIONS AND CONFIGURATIONS SO PROCEED WITH CAUTION!
  5. Open a Finder window and find your existing Anaconda folder (mine was in my home directory and was named Anaconda). Drag it to the Trash. This is faster than removing it from the command line, but if you want to do it that way issue rm -rf ~/Anaconda <enter>. Empty your Trash.
  6. Run the miniconda bash install script by issuing bash Miniconda3-latest-MacOSX-x86_64.sh <enter>. If you downloaded the script to your Downloads you of course must be in the Downloads folder to run it. You will be prompted to read and approve some legalese so just play along. Eventually the script will do its thing. I wasn’t asked to authenticate anything. Approve all changes or suggestions the installer wants to make. You can discard the installation script after it has run to completion.
  7. At this point, the basic installation is done and you’re almost ready to install the VPython packages, but first you need to make sure your system path is correctly set. macOS 10.15 (Catalina) uses zsh as the default command line shell whereas previous versions used bash as the default shell. Don’t worry because bash is still there and you can obviously still run bash scripts, but it’s not the default shell now. Do step 7a if you have not yet updated to Catalina. Otherwise, do step 7b.
    1. Prior to Catalina, when you installed the full Anaconda distribution, your system PATH was altered and stored in the .bash_profile file in your home directory (~/). It was also altered just now when you installed miniconda. If you have not yet updated to Catalina, get into your home directory and use a command line text editor (I prefer pico) to edit your .bash_profile file to remove the PATH section referring to the Anaconda installer. Just delete that entire block. Leave the block referring to the miniconda installer. Save the edited file by overwriting the existing one. To make the PATH changes take effect, you now need to exit Terminal and reopen it. Issuing echo $PATH <enter> should show an entry referring to your miniconda folder and there should be no mention of an Anaconda folder. Before moving to the next step, issue source ~/miniconda3/bin/activate <enter> and then conda init <enter>. This activates Anaconda’s ability to recognize and tell you at the system prompt which environment is currently active. You may need to exit Terminal and reopen it for the PATH change to take effect.
    2. In Catalina, zsh is the default command line shell. Issue source ~/miniconda3/bin/activate <enter> and then conda init zsh <enter> to correctly modify your system PATH. You may need to exit Terminal and reopen it for the PATH change to take effect.
  8. Now install VPython currently version (7.6.1) by issuing conda install -c vpython vpython <enter>. This will also install all required dependencies, including Jupyter Notebook and friends.
  9. I recommend doing one final thing, and that is setting a default browser for using Jupyter Notebook. Otherwise, your system’s default browser will be used. I prefer Google Chrome, but I also like Firefox so I sometimes use one or the other. To set a default Jupyter Notebook browser, issue
    jupyter notebook –generate-config <enter> (yes, that’s two dashes before the option). This will create a folder named .jupyter in your home directory and in that folder will be a file named jupyter_notebook_config.py. Open this file in a command line text editor (I use pico) and look for the line beginning with c.NotebookApp.browser and edit it to bec.NotebookApp.browser = u’open -a /Applications/Google\ Chrome.app %s’


    c.NotebookApp.browser = u’open -a /Applications/Firefox.app %s’
    and save the edited file and exit the editor. GET OUT OF THE .jupyter DIRECTORY BY ISSUING SOMETHING LIKE cd .. <enter>. If you now issue jupyter notebook <enter> you should launch with your chosen default browser.
  10. One final convenient configuration can be set, and that is the default folder to start your browser in. I have a folder Documents/VPython where I keep my VPython programs and Jupyter Notebooks. Edit the jupyter_notebook_config.py file and look for the line beginning with c.NotebookApp.notebook_dir and edit it to be something similar to mine, which isc.NotebookApp.notebook_dir = ‘/Users/heafnerj/Documents/VPython’and save the file and exit the editor. I seem to recall having some kind of problem with using ‘~/Documents/VPython’ but I don’t recall the details. GET OUT OF THE .jupyter DIRECTORY BY ISSUING SOMETHING LIKE cd .. <enter>. If you now issue jupyter notebook <enter> you should launch with your chosen default browser and you should start up in your chosen directory.

After I did this, my miniconda folder clocks in at 3.15GB, considerably smaller than before. My iMac now has a 2TB SSD so I have plenty of disk space to spare, but I don’t like using more than is necessary. Please let me know of mistakes in these instructions and I’m open to suggestions for increased clarity.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.