A Minimalist VPython Setup with Miniconda

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.

If you have an icon for Anaconda Navigator in your Dock, remove it (I’m assuming you know how to do that.).

Download the miniconda installation script from this page and stick it somewhere. I put it in my home folder for no really good reason. It’s a bash script and you’ll need it later.

Open a Terminal. Install the anaconda-clean package by issuing

conda install anaconda-clean and pressing enter.

Issue anaconda-clean and press 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!

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 and press enter. Empty your Trash.

Run the miniconda bash install script by issuing

bash Miniconda3-latest-MacOSX-x86_64.sh and pressing enter. 

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.

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. 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. Get into your home directory and use a plain text editor (I prefer pico) to edit your .bash_profile file to remove the 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 and pressing enter should show an entry referring to your miniconda folder and there should be no mention of an Anaconda folder.

Now you can install all of the VPython packages by issuing

conda install -c vpython vpython and pressing enter.

The latest version of VPython (currently 7.0.3) will be installed. Everying, including Jupyter notebooks, should work now. If you need any additional packages not related to VPython you can now install them individually.

I did one final thing, and that is to make sure Chrome is the default browser for Jupyter notebooks. If you also want to do this, read on. Issue

jupyter notebook –generate-config (that’s two dashes before the option) and press enter to generate a file named jupyter_notebook_config.py in the .jupyter folder in your home directory.

You need to edit the new configuration file to make Chrome the default browser. Load the file into a text editor (again, I used pico) and look for the line containing c.NotebookApp.browser and edit it to be

c.NotebookApp.browser = u’open -a /Applications/Google\ Chrome.app %s’

and save the edited file and exit your editor. Be sure to get out of the .jupyter directory before running anything.

You can now issue jupyter notebook and you should be up and running with a fresh notebook environment in Chrome.

After I did this, my miniconda folder clocks in at 2.09GB, considerably smaller than before. Obviously, with a fresh install (i.e. starting from scratch with just miniconda) one need not worry about path issues. I think this may be better for beginning VPython users than using a full Anaconda installation.

One thought on “A Minimalist VPython Setup with Miniconda

Leave a Reply

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