some_name.py
some_name.py

Reputation: 827

Python: Set permissions for pip or conda in /opt directory

I installed python via Anaconda to my /opt directory (I heard that's the proper way when all users should be able to use it).

Everything is working fine so far, up to the point when I try to install packages via pip or conda. Than I get permission issues for both ways. When I try to do:

sudo pip install pandas-datareader

I get:

sudo: pip: command not found

and the same error results if I try to use conda as well.

Does anyone have an idea how to fix that?

Upvotes: 2

Views: 2392

Answers (3)

Heapify
Heapify

Reputation: 2901

You are getting that error because 'sudo' uses its own secure path and not user's path determined by bash environment variable PATH. sudo's secure path is mentioned in the /etc/sudoers file by a variable named "secure_path". In order for the sudo to see pip/conda, you should ask your administrator to add "/opt/anaconda/bin" to the secure_path variable. That should fix the issue. Hope it was helpful. Here is what a typical sudoers file may look like: enter image description here

Upvotes: 0

Linda
Linda

Reputation: 1123

You don't need to run conda or pip with sudo. Just run pip install pandas-datareader.

Upvotes: 0

Burhan Khalid
Burhan Khalid

Reputation: 174662

The /opt folder is not in the global path, so when you sudo it is not available.

You may want to sudo -E to preserve any environment variables, which will likely include a customization to the PATH variable to include the directory where pip is installed in /opt

Alternatively, you can give the full path to the command sudo /opt/anaconda-path/bin/pip

Upvotes: 3

Related Questions