5

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.

4
  • It's not an error, it's a warning. Big difference. Errors stop the script. Warnings continue the script. Read your output: The warning message itself provides two options - choose one and then do it. – user535733 May 21 '20 at 18:38
  • my bad, apologize for that but I'm unable to use it. – Vinay May 21 '20 at 18:50
  • Are you saying that you do not understand the two options presented? Or that you are hoping for additional options? Or that you don't understand how to implement your chosen solution? Or something else? What is your question? – user535733 May 21 '20 at 18:52
  • after installing virtualenv, I'm unable to use it and yes I don't know how to fix this though I want to change my path so that every package I install using pip in future won't get this warning. – Vinay May 21 '20 at 19:16
7

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

2
  • 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 '20 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. – B. du Garay May 21 '20 at 19:38
4

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.

1
  • 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 at 18:45

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.