![](/img/trans.png)
[英]Python: Could not install packages due to an OSError: [Errno 2] No such file or directory
[英]Could not install packages due to an OSError: [WinError 2] No such file or directory
尝试以管理员身份运行命令:
或者
pip install numpy --user
无需任何特殊权限即可安装 numpy
我对其他包也有同样的问题。 试试看嘛
pip install 'package name' --user
并查看问题是否已解决。 它对我有用。
您尝试安装的 package 似乎已经存在,或者您没有安装它的权限。
首先尝试import numpy
并使用。 如果它不起作用,请尝试第二个选项。
通过运行以下命令,尝试以用户权限再次install numpy
:
pip install numpy --user
这是特权问题。 就我而言,在强制安装tensorflow_gpu
时弹出了一个wheel.exe
错误。 我通过在命令末尾添加--user
来逃避它。
pip3 install --upgrade --force-reinstall tensorflow-gpu --user
查看 C/python/Scripts 目录属性,该文件夹被标记为只读。 更改以解决问题
我也刚遇到这个。 对我来说,这是因为我忘记激活我的 conda 环境,它安装了 numpy。
检查建议您尝试导入 numpy 的答案并尝试一下。 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),或在您忘记激活的特定 conda/pyenv/venv/other 环境中。
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
无论哪种方式,您都应该能够安装/重新安装 numpy,并在激活的 python 安装和环境中获取 f2py.exe 文件。
我在 win 10 中遇到了同样的问题,但问题似乎不是 numpy。
我正在使用pip install pyev3
看到这个问题并来到这里。
我运行pip uninstall numpy
然后pip install pyev3
- 没有变化,仍然失败。
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.
如果您有类似的问题,希望这会有所帮助。
我在安装 InstagramScrapper 时遇到了错误
pip3 isntall instagramscraper --user
这个对我有用
该问题似乎并非特定于 numpy,并且提升的管理员提示对我有用。 我使用gsudo为我正在安装的软件包(恰好包括 numpy)提升了正常的 powershell 提示。
这是一个示例 session(为简洁起见,有些部分用...
省略了):
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'
修复:
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 ...
尝试以管理员身份运行命令提示符,同时使用命令>> pip install django
在我的例子中,从c:\users\(username)\appdata\roaming\
删除python
文件夹解决了这个问题,因为我已经在c:\
驱动器根目录中安装了 python。
在 windows 中,右键单击 Python 文件夹(我的是 c:\Python311),然后在安全面板中将您当前的用户添加为拥有该文件夹访问权限的所有者。
您只需在行后添加--user
即可。 这是最好的答案!
解决该错误的一种方法是安装范围为当前用户的 package,无需提升权限。 试试这个
pip install beautifulsoup4 certifi cffi charset-normalizer --user
尝试以管理员身份运行命令提示符
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.