25
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/beautifulsoup4-4.6.0.dist-info'Consider using the `--user` option or check the permissions.

The error above is the one I get when I try to use the pip command. All I need to do is pip install the requirements.txt to get my program to work. I have python 2.7.1 installed and placed my code where I am able to use python commands. I tried to change permissions by using this command:

chmod -R 777

but it did not work. I have homebrew installed on my computer. I also tried to use a virtual environment using this link: http://sourabhbajaj.com/mac-setup/Python/virtualenv.html but it gave me permission issues as well. Is there any suggestions to get rid of this permissions issue and run pip successfully? The sudo command below also doesn't work.

sudo pip install -r requirements.txt
Sam
  • 319
  • 1
  • 4
  • 11
  • Possible duplicate of [pip install -r: OSError: \[Errno 13\] Permission denied](https://stackoverflow.com/questions/31512422/pip-install-r-oserror-errno-13-permission-denied) – phd May 07 '18 at 01:25

3 Answers3

40

This is a permissions issue.

Consider using pip install "packagename" --user as mentioned in the error. This is covered HERE

Aidan Ross
  • 516
  • 5
  • 4
  • tried this and I still have some permission issues, but the link helped the most so thanks – Sam May 07 '18 at 16:40
  • I tried this, and the package appears to have installed successfully, **pip install python-docx --user Collecting python-docx Requirement already satisfied: lxml>=2.3.2 in /Library/Python/2.7/site-packages (from python-docx) (4.2.3) matplotlib 1.3.1 requires nose, which is not installed. matplotlib 1.3.1 requires tornado, which is not installed. Installing collected packages: python-docx Successfully installed python-docx-0.8.6** the package is not showing in my site-packages folder and I can't use it. Mac high sierra, python 3.7, Pycharm 2018. Thanks. – Chris22 Jul 15 '18 at 06:27
  • 1
    I used the --user flag and it said "Successfully installed pip-18.1" but then I get "-bash: pip: command not found" when I try to use it. Any ideas? – aris Dec 23 '18 at 02:03
1

try using sudo pip install djangorestframework for Mac. Worked for me.

Ravi Shankar Bharti
  • 8,922
  • 5
  • 28
  • 52
Beni
  • 35
  • 2
  • 2
    Be very careful about doing `sudo` during package installation. It gives root access to possibly malicious packages. It's best to use `--user` to insulate things from the rest of the system https://askubuntu.com/questions/802544/is-sudo-pip-install-still-a-broken-practice – Serguei Fedorov May 21 '19 at 19:23
0

It is likely that the directory where the package's entry point was installed is not in your PATH. For example, if it was installed /Users/username/Library/Python/3.7/bin/script, add PATH=$PATH:/Users/username/Library/Python/3.7/bin/ to your shell rc (.bashrc, .bash_profile, etc), and you should be good (and that will solve issues with other scripts installed to that /bin folder.