Skip to content
Using a Pipfile with pipenv on Binder
Jupyter Notebook Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests Add demonstrative test of python ver Jun 26, 2019
LICENSE Initial non-dummy commit Jun 26, 2019
Pipfile Add demonstrative test of python ver Jun 26, 2019
Pipfile.lock
README.md Use https in links Jun 26, 2019
index.ipynb

README.md

Python environment with Pipfile / Pipfile.lock

This is a mybinder.org, BinderHub, and repo2docker compatible git repository to automatically get the Python dependencies found within Pipfile / Pipfile.lock installed by pipenv and runnable on a BinderHub such as mybinder.org.

It is meant to showcase how you can make your own git repository compatible as well, allowing visitors to click a button and start running your code!

Imagine...

Imagine someone expecting to run code within a git repository, after simply clicking a button link like this one, because someone suggested that possibility...

Binder

This person would end up mybinder.org and see a loading bar - what is going on?

mybinder.org runs a BinderHub hosted on multiple clouds. BinderHub will with the help of repo2docker both construct a Dockerfile and build the Dockerfile into an Docker image. This image can with the help of a JupyterHub, also on the cloud, be launched into a Docker container. This container can be considered a virtual computer that mybinder.org dedicates to the visitor. This virtual computer was, within the link to mybinder.org, asked to be accessed from Jupyter Lab. From Jupyter Lab, the visitor could then experiment with the code found in the git repository.

Notes

The Pipfile.lock, or Pipfile if there is no lock file, should list all Python libraries that your code depend on. They will be installed directly into the main Python environment using the --system flag of pipenv. Also note that the --dev flag will be used to install also the development dependencies.

When both Pipfile and Pipfile.lock are found, --ignore-pipfile will be passed to pipenv to make the Pipfile.lock get prioritized as seemed reasonable for better reproducibility, so make sure to use run pipfile lock to update your Pipifile.lock in the git repository if you add a dependency to a Pipfile.

If you run this repo on mybinder.org, you can verify that the --dev dependencies were installed by running pytest directly from a terminal, and by doing so you also verify that the packages was installed in the main Python environment.

Get started using pipenv and Pipfile's

You can install Python dependencies with pipenv like this:

pip install pipenv
pipenv install --dev pytest
pipenv install numpy

And use them like this:

pipenv run python -c 'import numpy; print("Hi numpy version {}".format(numpy.__version__))'

And also use them like this:

pipenv shell
python -c 'import numpy; print("Hi numpy version {}".format(numpy.__version__))'

References

You can’t perform that action at this time.