Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'"

PythonMacosNumpy

Python Problem Overview


I am trying to install numpy on macOS X but after executing the command pip install numpy I am getting the error:

> Environment error :[error 13]: permission denied : 'usr/local/bin/f2py

How do I fix it?

Python Solutions


Solution 1 - Python

This worked for me.

pip3 install --user package-name  # for Python3
pip install --user package-name   # for Python2

The --user flag tells Python to install in the user home directory. By default it will go to system locations. credit

Solution 2 - Python

pip install --user package-name

Seems to work, but the package is install the the path of user. such as : > "c:\users\***\appdata\local\temp\pip-req-tracker-_akmzo\42a6c7d627641b148564ff35597ec30fd5543aa1cf6e41118b98d7a3"

I want to install the package in python folder such c:\Python27. I install the module into the expected folder by:

pip install package-name --no-cache-dir

Solution 3 - Python

I am also a Windows user. And I have installed Python 3.7 and when I try to install any package it throws the same error that you are getting.

Try this out. This worked for me.

python -m pip install numpy

And whenever you install new package just write

python -m pip install <package_name>

Hope this is helpful.

Solution 4 - Python

I too had to face the same problem. This worked for me. Right click and run as admin than run usual command to install. But first run update command to update the pip

python -m pip install --upgrade pip

Solution 5 - Python

Well, in my case the problem had a different cause, the Windows path Length Check this.

I was installing a library on a virtualenv which made the path get longer. As the library was installed, it created some files under site-packages. This made the path exceed Windows limit throwing this error.

Hope it helps someone =)

Solution 6 - Python

As a windows user, run an Admin powershell and launch :

python -m pip install --upgrade pip

Solution 7 - Python

I just ran the command with sudo:

sudo pip install numpy

Bear in mind that you will be asked for the user's password. This was tested on macOS High Sierra (10.13)

Solution 8 - Python

I had the same problem for different package. I was installing pyinstaller in conda on Mac Mojave. I did

conda create --name ai37 python=3.7
conda activate ai37

I got the mentioned error when I tried to install pyinstaller using

pip install pyinstaller

I was able to install the pyinstaller with the following command

conda install -c conda-forge pyinstaller 

Solution 9 - Python

If you are already using an virtual env on ubuntu and if you get this error,then navigate to your virtual env folder.If you see a lock symbol like:

folder created with root priviledge

Then you don't have the appropriate permission as a user to pip install inside this.Hence change the permission of the venv folder using this command:

sudo chown -R $USER path/to/venv

Now switch to the venv and install your package.

Solution 10 - Python

On Windows this has worked for me. From the command line, specify the path to the exe for Python: & "C:/Program Files (x86)/Python37-32/python.exe" -m pip install --upgrade pip --user

Solution 11 - Python

It is always preferred to use a virtual environment ,Create your virtual environment using :

python -m venv <name_of_virtualenv>

go to your environment directory and activate your environment using below command on windows:

env_name\Scripts\activate.bat

then simply use

pip install package_name

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSid MehtaView Question on Stackoverflow
Solution 1 - PythonSolitaryReaperView Answer on Stackoverflow
Solution 2 - PythonAndyView Answer on Stackoverflow
Solution 3 - Pythonshreyans jainView Answer on Stackoverflow
Solution 4 - Pythongetek merView Answer on Stackoverflow
Solution 5 - PythonJoabe LucenaView Answer on Stackoverflow
Solution 6 - PythonsancelotView Answer on Stackoverflow
Solution 7 - PythonLucio MollinedoView Answer on Stackoverflow
Solution 8 - PythonMian Asbat AhmadView Answer on Stackoverflow
Solution 9 - PythonSavannah MadisonView Answer on Stackoverflow
Solution 10 - Pythonuser2867432View Answer on Stackoverflow
Solution 11 - PythonTomato MasterView Answer on Stackoverflow