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

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?

This question is related to python macos numpy

The answer is

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 =)

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

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 

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)

pip install --user package-name

Seems to work, but the package is install the the path of user. such as :


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

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

python -m pip install --upgrade pip

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

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:


then simply use

pip install package_name

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

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.

Examples related to python

programming a servo thru a barometer Is there a way to view two blocks of code from the same file simultaneously in Sublime Text? python variable NameError Why my regexp for hyphenated words doesn't work? Comparing a variable with a string python not working when redirecting from bash script is it possible to add colors to python output? Get Public URL for File - Google Cloud Storage - App Engine (Python) Real time face detection OpenCV, Python xlrd.biffh.XLRDError: Excel xlsx file; not supported Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation

Examples related to macos

Problems with installation of Google App Engine SDK for php in OS X dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac Could not install packages due to an EnvironmentError: [Errno 13] How do I install Java on Mac OSX allowing version switching? Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Can't compile C program on a Mac after upgrade to Mojave You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user) How can I install a previous version of Python 3 in macOS using homebrew? Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'"

Examples related to numpy

Unable to allocate array with shape and data type How to fix 'Object arrays cannot be loaded when allow_pickle=False' for imdb.load_data() function? Numpy, multiply array with scalar TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array Could not install packages due to a "Environment error :[error 13]: permission denied : 'usr/local/bin/f2py'" Pytorch tensor to numpy array Numpy Resize/Rescale Image what does numpy ndarray shape do? How to round a numpy array? numpy array TypeError: only integer scalar arrays can be converted to a scalar index