velapanur
velapanur

Reputation: 335

How can I run pip without a sudo (for mac)? It doesnt work without sudo

I am trying to install python and pip. When I try to install pip, it says that it's already present, running the below command,

python get-pip.py
Requirement already up-to-date: pip in /Library/Python/2.7/site-packages/pip-1.5.6-   py2.7.egg

But when I try the pip command, it says

user1$ pip
-bash: pip: command not found

How do I solve this ?

Upvotes: 0

Views: 1198

Answers (2)

James Sullivan
James Sullivan

Reputation: 126

First you need to find where it is.

locate pip

You're looking for the binary so you want to narrow it down to ..../bin/.... paths, generally.

locate pip | grep bin

As an alternative to the above, if you can run pip while under sudo, try running sudo which pip to give you the path to it.

Once you find something promising (mine is /usr/bin/pip, for example), open up ~/.bashrc and add a line alias pip=your/bin/path. Then you have to update bash's source so do source ~/.bashrc and you should be able to run pip.

As a sidenote, I (and many others) prefer to keep all of my alias definitions in a separate file to keep things clean, so I use ~/.bash-aliases for all of my alias definitions and then in ~/.bashrc you want these lines:

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

Which pulls all the aliases out of ~/.bash-aliases for you.

Upvotes: 1

user3525381
user3525381

Reputation: 227

If it was a sudo issue, you wouldn't be getting "command not found". Try an alias instead:

cd ~

vim .bashrc (or equivalent text editor if you don't have vim)

alias pip="path to pip" (obviously you'll want to put in the actual path)

Upvotes: 4

Related Questions