Pipenv: command not found

I am new to Python development and trying to use pipenv. I pip install pipenv that worked successfully:

 ... Successfully built pipenv pathlib shutilwhich pythonz-bd virtualenv-clone Installing collected packages: virtualenv, pathlib, shutilwhich, backports.shutil-get-terminal-size, pythonz-bd, virtualenv-clone, pew, first, six, click, pip-tools, certifi, chardet, idna, urllib3, requests, pipenv ... 

However, when I run the pipenv install command in the new project root, I get the following message: -bash: pipenv: command not found . I suspect that I may need to modify my .bashrc, but I do not understand what to add to the file or if modification is required.

+66
python pip pipenv
source share
13 answers

This is because you are not installing it globally (for the whole system). To make it available on your path you need to install it using sudo , for example like this:

 $ sudo pip install pipenv 
+68
source share

This is fixed for me:

 sudo -H pip install -U pipenv 
+73
source share

If you have completed the user installation, you need to add the desired folder to your PATH variable.

 PYTHON_BIN_PATH="$(python3 -m site --user-base)/bin" PATH="$PATH:$PYTHON_BIN_PATH" 

See pipenv installation instructions

+44
source share

I have the same problem with pipenv on Mac OS X 10.13 High Seirra, another Mac works just fine. I use Heroku to deploy my Django servers, some in 2.7 and some in 3.6. So I need both 2.7 and 3.6. When HomeBrew installs Python, it saves python points to source 2.7, and python3 points to 3.6.

The problem may be related to $ pip install pipenv . I checked / usr / local / bin and pipenv is not there. So, I tried to completely remove:

 $ pip uninstall pipenv Cannot uninstall requirement pipenv, not installed You are using pip version 9.0.1, however version 10.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. $ pip3 uninstall pipenv Skipping pipenv as it is not installed. 

Then reinstall and work now:

 $ pip3 install pipenv Collecting pipenv 
+11
source share

I tried this:

python -m pipenv # for python2

python3 -m pipenv # for python3

Hope this helps you.

+8
source share

OSX guys are here!

As @charlax replied (the best for me), you can use a more dynamic command to set PATH, but for Mac users this may not work , sometimes your USER_BASE path received from the site is incorrect, so you need to find out where your installation on python there is.

 $ which python3 /usr/local/bin/python3.6 

you will get a symbolic link, then you need to find the original symbolic link.

 $ ls -la /usr/local/bin/python3.6 lrwxr-xr-x 1 root wheel 71 Mar 14 17:56 /usr/local/bin/python3.6 -> ../../../Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 

(this ../../../ means root)

So, you have found the path to Python ( /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 ), then you just need to insert it into ~ ~ / .bashrc like this:

export PATH="$PATH: /Library/Frameworks/Python.framework/Versions/3.6/bin"

+5
source share

Where python stores packages

Before moving on to the command that installs pipenv , you should understand where pip installs Python packages .

Global site packages are where Python installs packages that will be available to all users and all Python applications on the system. You can check the global site package with the command

 python -m site 

For example, on Linux with Python 3.7, the path is usually

 /usr/lib/python3.7/dist-packages/setuptools 

Custom site packages are where Python installs packages available only to you. But packages will still be visible to all the Python projects you create. You can get the path with

 python -m site --user-base 

On Linux with Python 3.7, the path is usually

 ~/.local/lib/python3.7/site-packages 

Using Python 3.x

On most Linux and other Unix, usually Python 2 and Python 3 are installed in parallel. The default Python 3 executable is almost always python3 . pip may be available in the following cases, depending on your Linux distribution

 pip3 python3-pip python36-pip python3.6-pip 

Linux

Avoid using pip with sudo ! Yes, this is the most convenient way to install Python packages, and the executable is available at /usr/local/bin/pipenv , but it also means that a specific package is always visible to all users and all the Python projects you create. Instead, use site packages for each user instead of --user

 pip3 install --user pipenv 

pipenv is available on

 ~/.local/bin/pipenv 

Macos

On macOS, Homebrew is the recommended way to install Python . You can easily upgrade Python, install multiple versions of Python, and switch between versions using Homebrew.

If you are using Homebrew'ed Python, pip install --user disabled. The global package site is located at

 /usr/local/lib/python3.y/site-packages 

and you can safely install Python packages here. Python 3.y is also looking for modules in:

  /Library/Python/3.y/site-packages ~/Library/Python/3.y/lib/python/site-packages 

Window

For obsolete reasons, Python is installed in C:\Python37 . The Python executable is usually called py.exe , and you can run pip with py -m pip .

Global site packages installed in

 C:\Python37\lib\site-packages 

Since you usually don’t share your Windows devices, you can also install the global package

 py -m pip install pipenv 

pipenv now available on

 C:\Python37\Scripts\pipenv.exe 

I do not recommend installing Python packages on Windows with --user , because the directory of custom site packages is by default in your Windows roaming profile

 C:\Users\user\AppData\Roaming\Python\Python37\site-packages 

The roaming profile is used in Terminal Services (Remote Desktop, Citrix, etc.) and when logging in / out in a corporate environment. Slow login, logout, and reboot on Windows can be caused by a large roaming profile.

+3
source share

A global pipenv installation can have an adverse effect by rewriting the global / system -m anaged pip installation, which will result in import errors when you try to start pip.

You can install pipenv at user level:

pip install --user pipenv

This should install pipenv at the user level in /home/username/.local so that it does not conflict with the global version of pip. In my case, this did not work after running the --user switch, so I once ran the longer β€œfix what messed up” command to restore a managed system environment:

sudo python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall

^ found here: error after pip update: cannot import name 'main'

and then did the following:

mkdir/home/username/.local ... if it does not already exist

export PYTHONUSERBASE=/home/username/.local

Make sure the export takes effect (beat me once during this process):

echo $PYTHONUSERBASE

Then I ran pip install --user pipenv and everything was fine. Then I could run pipenv from the CLI, and it did not overwrite the pip system's global / system -m module. Of course, it depends on the user, so you have to make sure that you install pipenv in this way, working as the user you want to use pipenv.

Recommendations:

https://pipenv.readthedocs.io/en/latest/diagnose/#no-module-named-module-name https://pipenv.readthedocs.io/en/latest/install/#pragmatic-installation -of-pipenv https://pip.pypa.io/en/stable/user_guide/#user-installs

+2
source share

You might want to install pipenv via pipsi .

 curl https://raw.githubusercontent.com/mitsuhiko/pipsi/master/get -pipsi.py | python3 pipsi install pew pipsi install pipenv 

Unfortunately, there are some problems with macOS + python3 at the time of writing, see 1 , 2 . In my case, I had to change bashprompt to #!/Users/einselbst/.local/venvs/pipsi/bin/python

0
source share

This is fixed for me:

 sudo -H pip install -U pipenv 
0
source share

In some cases of the old version of pip :

 sudo easy_install pip sudo pip install pipenv 
0
source share

For window users, this may be due to an installation conflict with virtualenv. This worked for me when I first removed virtualenv and pipenv and then installed only pipenv.

 pip uninstall virtualenv pip uninstall pipenv pip install pipenv 

pipenv install xxx working for me pipenv install xxx

0
source share

After installing pipenv ( sudo pip install pipenv ), I continued to get a "Command not found" error when I tried to run the pipenv shell command.

I finally fixed it with the following code:

 pip3 install pipenv pipenv shell 
0
source share

All Articles