0

Recently I delete some files related to python 2.7 and now I'm crazy. I want to use pip to install python package for current user rather global user.

➜  ~ where pip
/usr/local/bin/pip

➜  ~ pip -V
pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)

In the past, I can install requests easily by pip install requests. But now I have to sudo pip install requests or pip install --user requests.

I think because of pip's location I have to install python package within /Library/Python/2.7/..... As you see, it needs root permission. I know venv can help me but now I want to know how to intall python package for current user.

CoXier
  • 2,523
  • 8
  • 33
  • 60
  • 1
    `--user` makes pip install packages in your home directory instead, which doesn't require any special privileges. – MortenB Jan 15 '18 at 08:34
  • Possible duplicate of [What is the purpose "pip install --user ..."?](https://stackoverflow.com/questions/42988977/what-is-the-purpose-pip-install-user) – Alex Huszagh Jan 15 '18 at 08:35
  • @MortenB I updated my question just now. – CoXier Jan 15 '18 at 08:38

1 Answers1

3

Use pip's --user option:

pip install --user package 

According to pip's documentation:

--user

Install to the Python user install directory for your platform. Typically ~/.local/, or %APPDATA%Python on Windows. (See the Python documentation for site.USER_BASE for full details.)

Community
  • 1
  • 1
Ronan Boiteau
  • 9,608
  • 6
  • 34
  • 56