I'm new to Python development and attempting to use pipenv. I ran the command pip install pipenv
, which ran 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 command pipenv install
in a fresh root project directory I receive the following message: -bash: pipenv: command not found
. I suspect that I might need to modify my .bashrc, but I'm unclear about what to add to the file or if modification is even necessary.
Installing pipenv globally can have an adverse effect by overwriting the global/system-managed pip installation, thus resulting in import errors when trying to run pip.
You can install pipenv at the user level:
pip install --user pipenv
This should install pipenv at a user-level in /home/username/.local so that it does not conflict with the global version of pip. In my case, that still did not work after running the '--user' switch, so I ran the longer 'fix what I screwed up' command once to restore the system managed environment:
sudo python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall
^ found here: Error after upgrading pip: cannot import name 'main'
and then did the following:
mkdir /home/username/.local
... if it doesn't already existexport PYTHONUSERBASE=/home/username/.local
Make sure the export took effect (bit me once during this process):
echo $PYTHONUSERBASE
Then, I ran the
pip install --user pipenv
and all was well. I could then run pipenv from the CLI and it did not overwrite the global/system-managed pip module. Of course, this is specific to the user so you want to make sure you install pipenv this way while working as the user you wish to use pipenv.References:
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
If you've done a user installation, you'll need to add the right folder to your
PATH
variable.See pipenv's installation instructions
OSX GUYS, OVER HERE!!!
As @charlax answered (for me the best one), you can use a more dynamic command to set PATH, buuut for mac users this could not work, sometimes your USER_BASE path got from site is wrong, so you need to find out where your python installation is.
you'll get a symlink, then you need to find the source's symlink.
(this
../../../
means root)So you found the python path (
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
), then you just need to put in you ~/.bashrc as follows:export PATH="$PATH:/Library/Frameworks/Python.framework/Versions/3.6/bin"
In some cases of old
pip
version:For window users this may be due to conflicting installation with virtualenv. For me it worked when I uninstalled virtualenv and pipenv first, and then install only pipenv.
Now
pipenv install xxx
worked for meThis is fixed for me to: