This error occurs because Python environment is managed by the operating system, preventing modifications to the system-wide installation using pip
. To resolve this, you can create a virtual environment, which allows you to manage your own Python packages without affecting the system’s Python environment. Here are the steps:
Install the
python3-venv
package:1
sudo apt install python3-venv
Create a virtual environment:
1
python3 -m venv myenv
Activate the virtual environment:
1
source myenv/bin/activate
Install
ipykernel
in the virtual environment:1
pip install ipykernel -U
By using a virtual environment, you can install and manage Python packages without interfering with the system’s Python installation. If you need to exit the virtual environment, simply run:
1 | deactivate |
-------------本文结束感谢您的阅读-------------