[英]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.