LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   'sudo pip install' is not recognized. 'pip install' is recognized. (https://www.linuxquestions.org/questions/linux-newbie-8/sudo-pip-install-is-not-recognized-pip-install-is-recognized-4175679564/)

MrBright2019 07-28-2020 09:58 PM

'sudo pip install' is not recognized. 'pip install' is recognized.
 
On Ubuntu 20, I created a virtual environment(venv) like this:
sudo python3 -m venv my-env

I do activate and I get into the venv:
(code-env) mr@ubuntu:~/code-env$ sudo pip install git+https://github.com/user/c-gnmi
[sudo] password for mr:
sudo: pip: command not found

Then if I attempt without 'sudo', it is recognized but I get an error stating permission denied.
(code-env) mr@ubuntu:~/code-env$ pip install git+https://github.com/user/certain-script

Running setup.py clean for c-gnmi
Failed to build c-gnmi
Installing collected packages: six, pycparser, cffi, cryptography, grpcio, protobuf, c-gnmi
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/home/c/code-env/lib/python3.8/site-packages/six.py'
Consider using the `--user` option or check the permissions.


Can someone explain how 'sudo pip install' is not recognized? I tried pip3 and same behavior.

berndbausch 07-28-2020 10:09 PM

Quote:

Originally Posted by MrBright2019 (Post 6150464)
Can someone explain how 'sudo pip install' is not recognized? I tried pip3 and same behavior.

For security reasons, sudo removes most of your environment variables. Run sudo -i and look at PATH. pip is probably in a directory that is not included in sudo's PATH.

You can change that behaviour in the sudoers file. See https://www.sudo.ws/man/1.8.15/sudoe...nd_environment.

Or you first run sudo -i, then enter the virtual environment.

Here is another discussion of this problem: https://askubuntu.com/questions/2347...lenv-with-sudo.


All times are GMT -5. The time now is 04:27 PM.