I know this sounds like a pretty basic question but i've been frustrating myself to no end for the better part of a day. Am trying to set up a python environment in Windows Subsystem for Linux and everything seems to break when I install pipenv.

Steps to reproduce:

  1. Fresh install of Ubuntu 18.04 from windows store

  2. sudo apt update && sudo apt upgrade

  3. sudo apt install python3-pip

  4. pip3 install --user pipenv

Pip outputs everything i would expect, no errors, looks like pipenv is installed.

if I try use pipenv i get pipenv: command not found even though my local bin is in my PATH

worse than that though, pip is now broken and attempting to use pip gives me the following:

Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
ImportError: cannot import name 'main'

So it seems like the pipenv installation ruined the system pip by trying to install its own. I thought the --user flag would have avoided that but anyways am stuck, any help appreciated.

  • The ImportError you get, it's not because of pipenv. It's caused by pip upgrading from 9.0 to 19+. I can reproduce it 100% of the time..
    – Joe
    Aug 30, 2019 at 13:19

6 Answers 6


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
  • 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
$ pipenv --version
pipenv, version 2018.11.26

In my case, logout/login after pipenv installation helped - this will apply PATH changes in .profile file.


We ran into issues just like you did. You may try the following, since it works for us:

$ sudo apt update
$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:deadsnakes/ppa

Don´t upgrade yet, takes longer.

Edit ~/.profile, like Biswapriyo´s answer above. Ours, we add:

# Add home user directory to path
export PATH="/home/$USER/.local/bin:$PATH"

Then proceed with the commands below:

$ sudo apt install python3.7 python3-pip -y
$ python3.7 -m pip install --user pip
$ python3.7 -m pip install --user pipenv

Then, we run commands like this:

$ python3.7 -m pipenv check

python3.7 -m pipenv check

UPDATE: You can also use it like this:

$pipenv check --python=`which python3.7`

Found this answer at 2018.11.26: pipenv emits pythons errors when creating a virtualenv #3363


In my case I used ZSH in Ubuntu WSL. I had to add the $HOME/.local/bin to the PATH in ~/.zshrc and restart my session


Install Pipenv

for Python3:

python3 -m pip install --user pipenv

or for python2:

python -m pip install --user pipenv

The scripts pipenv and pipenv-resolver are installed in /home/<username>/.local/bin which is not on PATH

Add ~/.local/bin to PATH

echo 'export PATH="${HOME}/.local/bin:$PATH"' >> ~/.bashrc

After that you will be able to create your own isolated python environment. Go inside your project folder, let's suppose it's called python-helloworld:

pipenv shell

You will receive a message like:

✔ Successfully created virtual environment! Virtualenv location: /home//.local/share/virtualenvs/python-helloworld-Bn_pnRzN

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.