How to properly install Pipenv on WSL Ubuntu 18.04?

If pipenv installed successfully there will be a short notice like this:

The scripts pipenv and pipenv-resolver are installed in '~/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

According to the documentation:

This does a user installation to prevent breaking any system-wide packages. If pipenv isn’t available in your shell after installation, you’ll need to add the user base’s binary directory to your PATH.

On Linux and macOS you can find the user base binary directory by running python -m site --user-base and adding bin to the end. For example, this will typically print ~/.local (with ~ expanded to the absolute path to your home directory) so you’ll need to add ~/.local/bin to your PATH. You can set your PATH permanently by modifying ~/.profile.

Follow this:

  • Open ~/.profile file.
  • Check if ~/.local/bin path exist in that file.
  • If not add these following lines
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi
  • Run bash --login for login mode because ~/.profile is executed for login shells.
  • Optionally, add those lines in ~/.bashrc for non login shell.


This works for me when I want to install a python package globally into /usr/local/bin/.

sudo -H pip3 install pipenv

If you are looking at installing it globally for the user, follow the method in the documentation:

pip3 install --user pipenv

Here is where I installed globally on a Ubuntu 18.0.4 machine:

$ sudo -H pip3 install pipenv
Collecting pipenv
  Downloading https://files.pythonhosted.org/packages/13/b4/3ffa55f77161cff9a5220f162670f7c5eb00df52e00939e203f601b0f579/pipenv-2018.11.26-py3-none-any.whl (5.2MB)
    100% |████████████████████████████████| 5.2MB 279kB/s 
Requirement already satisfied: pip>=9.0.1 in /usr/lib/python3/dist-packages (from pipenv)
Requirement already satisfied: setuptools>=36.2.1 in /usr/lib/python3/dist-packages (from pipenv)
Requirement already satisfied: virtualenv-clone>=0.2.5 in /usr/local/lib/python3.6/dist-packages (from pipenv)
Requirement already satisfied: virtualenv in /usr/local/lib/python3.6/dist-packages (from pipenv)
Requirement already satisfied: certifi in /usr/lib/python3/dist-packages (from pipenv)
Installing collected packages: pipenv
Successfully installed pipenv-2018.11.26
$ which pipenv
/usr/local/bin/pipenv
$ pipenv --version
pipenv, version 2018.11.26