[英]Issue when pip installing packages
請在這里查看我之前的問題。 我整天都在搜索我的問題是什么,但仍然遇到 pip 安裝問題。 這次我的錯誤信息有點不同。 自上一篇文章以來我做了什么:
C:\mysys64\mingw64\bin
已添加到系統環境變量下的路徑中c_cpp_properties.json
特別是 VSCode 中的"intelliSenseMode"
,從"windows-msvc-x64"
到"windows-gcc-x64"
C:\msys64\mingw64\include\python3.9\Python.h
下的我的 Python.h 文件,以確保錯誤已被#include <unistd.h>
消除。pip install Flask-SQLAlchemy
,現在我收到以下錯誤...終端 window output
Using cached Flask_SQLAlchemy-2.5.1-py2.py3-none-any.whl (17 kB)
Collecting SQLAlchemy>=0.8.0
Using cached SQLAlchemy-1.4.29.tar.gz (8.0 MB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: Flask>=0.10 in c:\msys64\mingw64\lib\python3.9\site-packages (from Flask-SQLAlchemy) (2.0.2)
Requirement already satisfied: itsdangerous>=2.0 in c:\msys64\mingw64\lib\python3.9\site-packages (from Flask>=0.10->Flask-SQLAlchemy) (2.0.1)
Requirement already satisfied: Jinja2>=3.0 in c:\msys64\mingw64\lib\python3.9\site-packages (from Flask>=0.10->Flask-SQLAlchemy) (3.0.3)
Requirement already satisfied: click>=7.1.2 in c:\msys64\mingw64\lib\python3.9\site-packages (from Flask>=0.10->Flask-SQLAlchemy) (8.0.3)
Requirement already satisfied: Werkzeug>=2.0 in c:\msys64\mingw64\lib\python3.9\site-packages (from Flask>=0.10->Flask-SQLAlchemy) (2.0.2)
Collecting greenlet!=0.4.17
Using cached greenlet-1.1.2.tar.gz (91 kB)
Preparing metadata (setup.py) ... done
Requirement already satisfied: colorama in c:\msys64\mingw64\lib\python3.9\site-packages (from click>=7.1.2->Flask>=0.10->Flask-SQLAlchemy) (0.4.4)
Requirement already satisfied: MarkupSafe>=2.0 in c:\msys64\mingw64\lib\python3.9\site-packages (from Jinja2>=3.0->Flask>=0.10->Flask-SQLAlchemy) (2.0.1)
Building wheels for collected packages: SQLAlchemy, greenlet
Building wheel for SQLAlchemy (setup.py) ... done
Created wheel for SQLAlchemy: filename=SQLAlchemy-1.4.29-cp39-cp39-win_amd64.whl size=1512539 sha256=80ef3cf51b84f92e8117a57097054fcb25807ebf7755115d7df299bacf17a09d
Stored in directory: c:\users\t\appdata\local\pip\cache\wheels\6d\94\a6\8bdac6f92ce851f71a9fa62934a06cf2b654700b5f258242c7
Building wheel for greenlet (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'C:\msys64\mingw64\bin\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\t\\AppData\\Local\\Temp\\pip-install-p182wkp5\\greenlet_78bb1f8ef93a452d8f0a86edfe24f6dd\\setup.py'"'"'; __file__='"'"'C:\\Users\\t\\AppData\\Local\\Temp\\pip-install-p182wkp5\\greenlet_78bb1f8ef93a452d8f0a86edfe24f6dd\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\t\AppData\Local\Temp\pip-wheel-iwgszyll'
cwd: C:\Users\t\AppData\Local\Temp\pip-install-p182wkp5\greenlet_78bb1f8ef93a452d8f0a86edfe24f6dd\
Complete output (69 lines):
然后像這樣的其他一些錯誤
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\msys64\mingw64\include -IC:\msys64\mingw64\include\python3.9 "-IC:\Program
Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\cppwinrt" /Tcsrc/greenlet/greenlet.c /Fobuild\temp.win-amd64-3.9\Release\src/greenlet/greenlet.obj
greenlet.c
C:\msys64\mingw64\include\python3.9\Python.h(36): fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.30.30705\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
----------------------------------------
ERROR: Failed building wheel for greenlet
Running setup.py clean for greenlet
Successfully built SQLAlchemy
Failed to build greenlet
Installing collected packages: greenlet, SQLAlchemy, Flask-SQLAlchemy
Running setup.py install for greenlet ... error
ERROR: Command errored out with exit status 1:
但是,在我的 Python.h 文件中, #include <unistd.h>
下不再有波浪線錯誤行。 請注意,我不知道我在嘗試解決此問題時在做什么。 如果有解決方案,請告訴我。
更新 2022.02.01:我卸載了 python 的3.9.7
版並安裝了3.10.2
版。 我已將 pip 更新到版本22.02.2
並嘗試了下面給出的解決方案。 下載 wheels greenlet‑1.1.2‑cp310‑cp310‑win32.whl
和greenlet‑1.1.2‑cp310‑cp310‑win_amd64.whl
后,我轉到我的下載文件夾並運行以下命令:
C:\Users\t\Downloads>C:\msys64\mingw64\bin\python.exe -m pip install greenlet-1.1.2-cp310-cp310-win_amd64.whl
ERROR: greenlet-1.1.2-cp310-cp310-win_amd64.whl is not a supported wheel on this platform.
C:\Users\t\Downloads>C:\msys64\mingw64\bin\python.exe -m pip install greenlet-1.1.2-cp310-cp310-win32.whl
ERROR: greenlet-1.1.2-cp310-cp310-win32.whl is not a supported wheel on this platform.
之后沒有工作我嘗試 pip 直接pip install greenlet
並得到以下 output:
Building wheels for collected packages: greenlet
Building wheel for greenlet (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [69 lines of output]
再往下
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for greenlet
Running setup.py clean for greenlet
Failed to build greenlet
Installing collected packages: greenlet
Running setup.py install for greenlet ... error
error: subprocess-exited-with-error
× Running setup.py install for greenlet did not run successfully.
│ exit code: 1
╰─> [71 lines of output]
再往下(希望這能對問題有所啟發)
error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.30.30705\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> greenlet
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
以下命令解決了我的 m1 Mac 上的問題 -
- brew install graphviz
- python3 -m pip install \
--global-option=build_ext \
--global-option="-I$(brew --prefix graphviz)/include/" \
--global-option="-L$(brew --prefix graphviz)/lib/" \
pygraphviz
您可以簡單地從這里下載適當的 whl 文件並安裝它。
對你greenlet‑1.1.2‑cp39‑cp39‑win_amd64.whl
應該是正確的。 下載后, cd
到你的下載目錄並運行
C:\msys64\mingw64\bin\python.exe -m pip install greenlet‑1.1.2‑cp39‑cp39‑win_amd64.whl
然后再次嘗試您的原始安裝。
筆記
同一網站上還有一個Flask_SQLAlchemy‑2.5.1‑py3‑none‑any.whl
的 whl 文件。 您也可以下載並安裝它
py -m pip
中的 pip 不同於pip list
中的 pip。 您可以通過py -m pip --version
和pip --version
獲取 pip 位置。
我可以通過以下方式成功安裝greenlet package:
pip install greenlet --no-cache-dir
我正在使用python310,看起來python39有一些問題。 如果它不起作用,正如@FlyingTeller 建議的那樣,您可以手動下載它。
正如您所描述greenlet-1.1.2-cp39-cp39-win_amd64.whl
不起作用,那么您是否嘗試過greenlet‑1.1.2‑cp39‑cp39‑win32.whl
?
>>> import platform
>>> platform.architecture()
您可以通過上述代碼獲得架構。
我更新了 pip 、 setuptools和wheel ,它解決了問題。
pip install --upgrade pip
pip install --upgrade setuptools wheel
注意:如果您的 pip 別名為 pip3 (Python 3),請使用 pip3 而不是 pip
pip3 install --upgrade pip
pip3 install --upgrade setuptools wheel
有關詳細信息,請參閱此鏈接: https://bobbyhadz.com/blog/python-error-legacy-install-failure
我在 Mac M1 上的 PyCharm 中安裝 greenlet 2.0.1 時遇到問題。
我升級了:
pip install --upgrade pip
pip install --upgrade setuptools wheel
感謝@joydeba 的評論——我已經安裝了 Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
*按照安裝結束時的說明進行操作
完成這些步驟后,我可以毫無問題地在 PyCharm 中安裝 greenlet!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.