12

I am using Ubuntu 20.04. Every time I try to install a package using pip I get a weird error.

pip3 install virtualenv
Collecting virtualenv
  Using cached virtualenv-20.0.21-py2.py3-none-any.whl (4.7 MB)
Requirement already satisfied: distlib<1,>=0.3.0 in ./.local/lib/python3.8/site-packages (from virtualenv) (0.3.0)
Requirement already satisfied: six<2,>=1.9.0 in /usr/lib/python3/dist-packages (from virtualenv) (1.14.0)
Requirement already satisfied: appdirs<2,>=1.4.3 in ./.local/lib/python3.8/site-packages (from virtualenv) (1.4.4)
Requirement already satisfied: filelock<4,>=3.0.0 in ./.local/lib/python3.8/site-packages (from virtualenv) (3.0.12)
Installing collected packages: virtualenv
  WARNING: The script virtualenv is installed in '/home/mark/.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.
Successfully installed virtualenv-20.0.21

How can I fix this error, please help.

0

2 Answers 2

21

On Ubuntu 20.04 simply log out of your account and log back in to fix that warning. This will re-evaluate your ~/.profile, which in turn automatically adds the ~/.local/bin folder to your path if it exists (which it does now, but probably hasn't before your first run of pip3 install).

After logging back in, virtualenv should work as expected and later runs of pip3 should not raise that warning anymore.

3
  • Thanks! I was annoyed that I need to add stuff to path manually, unlike in older versions - glad I saw this before manually running the command in the accepted answer.
    – mvishnu
    Apr 27, 2021 at 18:45
  • 3
    You don't have to log and out of your account, simply run . ~/.profile instead; this is much quicker way of reevaluating your .profile file. May 18, 2021 at 13:41
  • @SebastianNielsen indeed, but it only affects your current terminal session, not other concurrent ones nor future ones. So technically, it's a workaround and not a permanent fix.
    – Dreamer
    May 18, 2021 at 14:06
12

My answer fixed the issue but shouldn't have been the right answer. If you happened to be here because you are currently facing the very same issue that OP met, please refer to Dreamer answer first (and comments)


virtualenv is not in your PATH for some reason (not properly installed ? I believe it should be in your /user/local/bin/ or /user/bin/, I see you didn't use sudo ?). You can add it to your PATH with

echo "export PATH=\"/home/mark/.local/bin:\$PATH\"" >> ~/.bashrc && source ~/.bashrc

Edit : pip3 install PKG --no-warn-script-location to use the flag to ignore the warning

4
  • Thanks, now it's working perfectly fine. One more thing can you please explain what the above line did, I'm new in Ubuntu. Thanks once again.
    – Vinay
    May 21, 2020 at 19:22
  • PATH is directory where the commands you type on the terminal are. Here, you add the directory where virtualenv are, (echo "helloworld" >> file.txt add "helloworld" to the end of file.txt) to the .bashrc file, kind of "setting of your terminal", then reload it. Therefore the CLI as memorized the PATH. May 21, 2020 at 19:38
  • 1
    This should not be the accepted answer. See @Dreamer's answer. May 18, 2021 at 13:44
  • I do agree @Sebastian-Nielson for that. I didn't know why virtualenv/ wasn't in PATH and Dreamer got the point. May 18, 2021 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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