'Could not install packages due to an OSError: [WinError 2] No such file or directory
I try to use pip to install numpy, and I receive the following error message:
Python: Could not install packages due to an OSError: [Errno 2] No such file or directory 'c:\python39\Scripts\f2py.exe' -> 'c:\python39\Scripts\f2py.exe.deleteme'
I'm not sure about an older version of numpy installed first.
I ran just command prompt, not a one with admin privileges.
Can anyone help? Thanks.
Solution 1:[1]
Try running the command as administrator:
orpip install numpy --user to install numpy without any special previlages
Solution 2:[2]
I had the same problem with other packages. Just try
pip install 'package name' --user
and see if the issue is resolved. It worked out for me.
Solution 3:[3]
It seems like the package you are trying to install already exists, or you don't have privileges to install it.
First, try to
import numpyand use it. If it doesn't work, try the second option.Try to
install numpyagain with user privilege by running the command below:pip install numpy --user
Solution 4:[4]
Looking at the C/python/Scripts directory properties, the folder was marked as read-only. Changing that fixed the issue
Solution 5:[5]
It's a privileges issue. In my case, there was a wheel.exe error popping up while force installing tensorflow_gpu. I escaped it by adding --user at the end of the command.
pip3 install --upgrade --force-reinstall tensorflow-gpu --user
Solution 6:[6]
I also just encountered this. For me, it was because I forgot to activate my conda environment, which had numpy installed.
Check the answer recommending you try importing numpy and try that out. If numpy is unavailable, but you've installed numpy before, then most likely you have installed it either on another version of Python (one can have multiple versions installed - check your active version by typing python --version on the command line), or on a particular conda/pyenv/venv/other environment you forgot to activate.
For more info on Python package managers (which are out-of-scope for the question), see this guide: https://towardsdatascience.com/a-guide-to-conda-environments-bc6180fc533
Either way, you should be able to install/reinstall numpy, and get the f2py.exe file on your activated python installation and environment.
Solution 7:[7]
I had the same issue, in win 10, but it wasn't numpy that seems to have been the problem.
I was installing using pip install pyev3 saw this issue and came here.
I ran pip uninstall numpy then pip install pyev3 - no change, still failed.
I checked with pip list and numpy had been installed, so I then ran pip install hidapi, which worked and then ran pip install pyev3 which also then worked.
Hope this helps if you have a similar issue.
Solution 8:[8]
I was facing error while Installing InstagramScrapper I did with
pip3 isntall instagramscraper --user
it works for me
Solution 9:[9]
The problem doesn't appear to be specific to numpy, and an elevated administrator prompt worked for me. I used gsudo to elevate a normal powershell prompt for the packages I was installing (which happened to include numpy).
Here's a sample session (with some parts elided with ... for brevity):
PS > pip install -r pkgs.txt
Collecting black
Using cached black-22.3.0-cp310-cp310-win_amd64.whl (1.1 MB)
Collecting bs4
...
Installing collected packages: pycparser, cffi, attrs, ...
WARNING: Failed to write executable - trying to use .deleteme logic
ERROR: Could not install packages due to an OSError: [WinError 2] The system can
not find the file specified: 'C:\\Python310\\Scripts\\normalizer.exe' -> 'C:\\Py
thon310\\Scripts\\normalizer.exe.deleteme'
The fix:
PS > gsudo pip install -r pkgs.txt
Collecting black
Using cached black-22.3.0-cp310-cp310-win_amd64.whl (1.1 MB)
Collecting bs4
...
Installing collected packages: certifi, websockets, ...
Running setup.py install for path-and-address ... done
Running setup.py install for docopt ... done
Running setup.py install for bs4 ... done
Successfully installed Flask-2.1.1 Markdown-3.3.6 Pillow-9.1.0 PuLP-2.6.0 ...
Solution 10:[10]
Try running the command prompt as administrator works for me too while installing django using the command >> pip install django
Solution 11:[11]
Try running the command prompt as administrator
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow

