错误:无法构建pyzmq的轮子,这是安装基于pyproject.toml项目所需的。

5

由于安装ipykernel时出现问题,我无法在虚拟环境中使用VS Code上的Jupyter笔记本。当我切换到全局环境时,ipykernel可以成功安装并且我可以运行我的笔记本。

如果我创建一个新文件夹,进入该文件夹,运行python3 -m venv venv,然后运行source venv/bin/activate,接着运行code .,然后创建一个.ipynb文件并尝试在新单元格中执行任何代码,则VS Code会提示我安装ipykernel。因此我这样做了,然后VS Code会显示如下内容:

Running cells with 'Python 3.8.9 ('venv': venv)' requires ipykernel package.
Run the following command to install 'ipykernel' into the Python environment. 
Command: '/Users/my.name/Documents/test/venv/bin/python -m pip install ipykernel -U --force-reinstall'

我使用pip install ipykernel命令时遇到了以下错误:ERROR: Could not build wheels for pyzmq, which is required to install pyproject.toml-based projects。我正在运行MacBook M1 Pro上的macOS 12.5.1,使用Visual Studio Code版本为1.71.0,并在Python 3.8.9虚拟环境中操作。请问有哪些步骤可以解决这个问题?以下是一些其他看起来有用的错误信息:
Building wheels for collected packages: pyzmq
  Building wheel for pyzmq (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for pyzmq (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [174 lines of output]

      Loads of lines saying "copying something -> somewhere" which I've edited out

      buildutils/initlibzmq.cpp:10:10: fatal error: 'Python.h' file not found
      #include "Python.h"
               ^~~~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang++' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pyzmq
Failed to build pyzmq
ERROR: Could not build wheels for pyzmq, which is required to install pyproject.toml-based projects

1
在我的情况下,问题出在pyzmq的版本上。之前我使用的是Python3.8,当我切换到Python3.9时问题就出现了。所以,我指定了最新版本的pyzmq,问题就解决了。 - undefined
@MuhammadZubair 谢谢你的建议。对我也非常有效! - undefined
1个回答

0
尝试安装pyproject-toml==0.0.10 最新版本不起作用... 在pip安装pyzmq之后 一切正常进入图像描述

你不应该需要安装pyproject-toml。它是一个古老的草案项目。此外,pyproject-toml==0.0.10是该项目的最新版本。 - undefined
1
你的回答可以通过提供更多的支持性信息来改进。请编辑以添加进一步的细节,例如引用或文档,以便他人可以确认你的回答是否正确。你可以在帮助中心找到关于如何撰写好回答的更多信息。 - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接