I am unable to use Jupyter notebooks on VS Code within a virtual environment, due to a problem with installing ipykernel. When I switch to the global environment, ipykernel installs fine and I can run my notebooks.
If I make a new folder, enter it, run python3 -m venv venv
, then source venv/bin/activate
, followed by code .
, then make a .ipynb
file and try to execute any code in a new cell, then VS Code prompts me to install ipykernel. So I do that, and VS Code displays this:
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'
So I pip install ipykernel, and it throws this error at me:
ERROR: Could not build wheels for pyzmq, which is required to install pyproject.toml-based projects
I am running macOS 12.5.1 on a MacBook M1 Pro. Visual Studio Code version 1.71.0. My virtual environment is on Python 3.8.9.
What steps can be taken to resolve this?
Some other parts of the error that look useful:
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 pyzmqFailed to build pyzmqERROR: Could not build wheels for pyzmq, which is required to install pyproject.toml-based projects