fINSTALLING PACKAGES IN ANACONDA

Using the Command Line to Install Packages from GitHub

A quick dirty self note

Frank Ceballos
Frank Ceballos
Published in
3 min readJan 1, 2020

--

This is quick note to myself that describes how to install packages directly from GitHub using the command line. Usually, I find myself doing this when I cannot find the package I want to install in the Anaconda Cloud. I will try to be as thorough as possible since I always forget everything.

Note: This instructions were created and tested on a Mac OS but I'm certain that the commands will work in a Windows machine. It's assumed that the reader has already installed Anaconda.

Creating a Conda Environment

Let’s start by creating our a conda environment where we will install our package directly from GitHub. If you already know in which environment you want to install this package just activate it and skip this section.

Open your terminal. In Windows you can search for anaconda prompt in the Window search bar and in Mac OS simply find the terminal by searching for terminal in the finder.

Figure 1 — Mac OS terminal.

Once your terminal is open, create an environment with:

conda create --name MyEnvironmentName

Figure 2 — Creating environment. The environment name can be whatever you want. Just don’t use spaces.

Activate environment with:

conda activate MyEnvironmentName

Figure 3 — Activate environment.

Installing Necessary Packages

In order to install packages directly from GitHub, we need to first install the git and pip packages in you desired environment.

Install git with:

conda install git

Figure 4 — Installing git. You will be prompt if you want to proceed.

Install pip with:

conda install pip

Figure 5— Installing pip. You will be prompt if you want to proceed.

Installing Package from GitHub

Now we are ready to install packages directly from GitHub. In this example, we are going to install the MetaFlow package from Netflix. Here the package description:

Metaflow helps you design your workflow, run it at scale, and deploy it to production. It versions and tracks all your experiments and data automatically. It allows you to inspect results easily in notebooks.

Pretty cool ;)

So first we will grab the URL for the master branch. In this example, the URL for the master branch of the project MetaFlow is:

https://github.com/Netflix/metaflow

Then we need to remove https: and add .git to the end of this URL like so:

//github.com/Netflix/metaflow.git

To install the MetaFlow run the following pip command:

pip install git+git://github.com/Netflix/metaflow.git
Figure 6 — Installing MetaFlow directly from GitHub.

That’s it! To test it out, open Spyder by running the following command in the terminal:

spyder

And import Metaflow with:

import metaflow

If you get no ModuleNotFoundError then you are good to go.

Closing Remarks

In GitHub, the project repository has the following generic URL convention:

https://github.com/yourname/projectname

So in general to install a package from GitHub, open a terminal, activate the environment where you want to install this package, and run the following pip command:

pip install git+git://github.com/yourname/projectname.git

You’re welcome to connect with me on LinkedIn. Until next time and code every day!

--

--