【问题标题】:Issue when pip installing packagespip 安装包时的问题
【发布时间】:2022-01-17 16:35:09
【问题描述】:

请看我之前的问题here。我整天都在寻找我的问题是什么,但仍然遇到 pip install 问题。这次我的错误信息有点不同。自上一篇文章以来我做了什么:

  1. 确保在系统环境变量下将C:\mysys64\mingw64\bin 添加到我的路径中
  2. 编辑c_cpp_properties.json,特别是VSCode中的"intelliSenseMode""windows-msvc-x64""windows-gcc-x64"
  3. 重新检查我在目录C:\msys64\mingw64\include\python3.9\Python.h 下的Python.h 文件,以确保错误已被#include <unistd.h> 消除。
  4. 重试pip install Flask-SQLAlchemy,现在我收到以下错误...

终端窗口输出

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 并尝试了下面给出的解决方案。下载轮子greenlet‑1.1.2‑cp310‑cp310‑win32.whlgreenlet‑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 install greenlet pip install greenlet 并得到以下输出:

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.

【问题讨论】:

  • FWIW,当您 pip install SQLAlchemy 时,为什么不向我们展示您的错误?其余的,Jinja、Flask 等……只是在增加噪音。
  • 您可能需要调整您的 pip install 命令,仅适用于 SQLAlchemy,带有 -I-L 标志。例如,对于 Pygraphviz,文档给出了example。您可能需要多试几次,我必须在 上方 指出我最初认为的位置。
  • 是的,抱歉,我想,因为我不是专家,显示更多可能会更好。我浪费时间更新 Visual Studio 而不是 VSCode ......无论如何,这就是我所在的地方。我遵循this 指南。我跑了-m pip install --upgrade pip setuptools wheel,得到了这个WARNING: The script wheel.exe is installed in 'C:\Users\t\AppData\Roaming\Python\Python39\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  • 还有这个WARNING: The scripts pip.exe, pip3.9.exe and pip3.exe are installed in 'C:\Users\t\AppData\Roaming\Python\Python39\Scripts' which is not on PATH. 不确定这是否是个问题?然后我运行py -m pip install SQLAlchemy 命令并得到Installing collected packages: greenlet, SQLAlchemy Successfully installed SQLAlchemy-1.4.29 greenlet-1.1.2 但是当我运行pip list 命令时,两个包都没有列出......我不知所措

标签: python windows visual-studio-code pip


【解决方案1】:

您只需从here 下载适当的 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 文件。您也可以下载并安装它

【讨论】:

  • 您好,从我的下载C:\Users\t\Downloads>C:\msys64\mingw64\bin\python.exe -m pip install greenlet-1.1.2-cp39-cp39-win_amd64.whl ERROR: greenlet-1.1.2-cp39-cp39-win_amd64.whl is not a supported wheel on this platform.运行命令时出现以下错误@
【解决方案2】:

py -m pip 中的点与pip list 中的点不同。您可以通过py -m pip --versionpip --version获取pip位置。

我可以通过以下方式成功安装greenlet包:

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()

你可以通过上面的代码得到架构。

【讨论】:

  • win32 wheel 也出现了同样的错误。 C:\msys64\mingw64\bin\python.exe -m pip install greenlet-1.1.2-cp39-cp39-win32.whl ERROR: greenlet-1.1.2-cp39-cp39-win32.whl is not a supported wheel on this platform.
  • 手动下载是不是建议我从here的源文件类型中获取?
  • @Duke3e33 抱歉来晚了,platform.architecture() 的结果是什么?
  • 这是您要查找的信息吗?运行该命令后,这是输出 >>> import platform >>> platform.architecture() ('64bit', 'WindowsPE') >>>
  • @msys64 抱歉,您可以尝试安装普通的 python 吗?而不是与 msys64 相关?
【解决方案3】:

以下命令解决了我的 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

【讨论】:

    猜你喜欢
    • 2021-04-14
    • 1970-01-01
    • 2018-10-22
    • 2017-03-25
    • 1970-01-01
    • 2020-07-25
    • 2017-12-16
    • 1970-01-01
    • 2012-02-12
    相关资源
    最近更新 更多