简体   繁体   中英

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.

Try running the command as administrator:
or
pip install numpy --user to install numpy without any special previlages

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.

It seems like the package you are trying to install already exists, or you don't have privileges to install it.

  1. First, try to import numpy and use it. If it doesn't work, try the second option.

  2. Try to install numpy again with user privilege by running the command below:

     pip install numpy --user

I know its a bit late, however there maybe users still having the same issue. This is mostly a priviledge issue. You need to install numpy with as Admin.

  1. Open command prompt, and Run as Administator

在此处输入图像描述

  1. Now install numpy

    pip install numpy

在此处输入图像描述

and you should be good to go...

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

Looking at the C/python/Scripts directory properties, the folder was marked as read-only. Changing that fixed the issue

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.

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.

I was facing error while Installing InstagramScrapper I did with

pip3 isntall instagramscraper --user

it works for me

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 ...

Try running the command prompt as administrator works for me too while installing django using the command >> pip install django

In my case deleting python folder from c:\users\(username)\appdata\roaming\ solved the issue because I've python already installed in c:\ drive root directory.

In windows, right click on Python folder (mine is c:\Python311) and add your current user as owner with access rights onto the folder in the Security panel.

You just simply add --user after line. This is the best answer!

One way to solve the error is to install the package scoped to the current user, without requiring elevated privileges. Try this out

pip install beautifulsoup4 certifi cffi charset-normalizer --user

Try running the command prompt as administrator

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM