首先deepin-v23不让直接在本机安装kivy,害怕你把系统搞坏,因为现在大多数人是不懂linux系统的,都习惯了windows的操作环境,提示让你创建一个虚拟环境去安装,所以这时候要去安装一个虚拟环境,
自带的python没有安装python的虚拟环境管理工具,又要安装一下python的虚拟环境管理工具:
sudo apt install python3-full python3-venv
安装完虚拟环境管理工具,创建虚拟环境(这里我就创建一个名为kivyenv的虚拟环境):
python -m venv kivyenv
激活虚拟环境:
source kivyenv/bin/activate
安装kivy:
pip install kivy
顺便说一下,deepin-v23自带的python版本是3.12.4。
以下是deepin-v23直接在本机上使用pip安装kivy报错的内容:
–
rkey@rkey-PC:~$ pip install kivy
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.12/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing –break-system-packages.
hint: See PEP 668 for the detailed specification.
–
以下是我的deepin-v23自带的python版本信息:
–
(kivyenv) rkey@rkey-PC:~$ python
Python 3.12.4 (main, Jul 9 2024, 09:31:23) [GCC 13.2.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
>>>
–
以下是deepin-v23的python虚拟环境安装kivy控制台输出的日志:
–
(kivyenv) rkey@rkey-PC:~$ pip install kivy
Collecting kivy
Downloading Kivy-2.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 23.0/23.0 MB 19.6 MB/s eta 0:00:00
Collecting Kivy-Garden>=0.1.4 (from kivy)
Downloading Kivy_Garden-0.1.5-py3-none-any.whl (4.6 kB)
Collecting docutils (from kivy)
Using cached docutils-0.21.2-py3-none-any.whl (587 kB)
Collecting pygments (from kivy)
Using cached pygments-2.18.0-py3-none-any.whl (1.2 MB)
Collecting requests (from Kivy-Garden>=0.1.4->kivy)
Downloading requests-2.32.3-py3-none-any.whl (64 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 64.9/64.9 kB 8.8 MB/s eta 0:00:00
Collecting charset-normalizer<4,>=2 (from requests->Kivy-Garden>=0.1.4->kivy)
Downloading charset_normalizer-3.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (143 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 143.8/143.8 kB 20.1 MB/s eta 0:00:00
Collecting idna<4,>=2.5 (from requests->Kivy-Garden>=0.1.4->kivy)
Downloading idna-3.10-py3-none-any.whl (70 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 70.4/70.4 kB 10.6 MB/s eta 0:00:00
Collecting urllib3<3,>=1.21.1 (from requests->Kivy-Garden>=0.1.4->kivy)
Downloading urllib3-2.2.3-py3-none-any.whl (126 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 126.3/126.3 kB 19.9 MB/s eta 0:00:00
Collecting certifi>=2017.4.17 (from requests->Kivy-Garden>=0.1.4->kivy)
Downloading certifi-2024.8.30-py3-none-any.whl (167 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 167.3/167.3 kB 19.5 MB/s eta 0:00:00
Installing collected packages: urllib3, pygments, idna, docutils, charset-normalizer, certifi, requests, Kivy-Garden, kivy
Successfully installed Kivy-Garden-0.1.5 certifi-2024.8.30 charset-normalizer-3.4.0 docutils-0.21.2 idna-3.10 kivy-2.3.0 pygments-2.18.0 requests-2.32.3 urllib3-2.2.3
(kivyenv) rkey@rkey-PC:~$ pip list
Package Version
—————— ———
certifi 2024.8.30
charset-normalizer 3.4.0
docutils 0.21.2
idna 3.10
Kivy 2.3.0
Kivy-Garden 0.1.5
pip 23.1.2
Pygments 2.18.0
requests 2.32.3
urllib3 2.2.3
(kivyenv) rkey@rkey-PC:~$ pip install kivy-examples
Collecting kivy-examples
Downloading Kivy_examples-2.3.0-py2.py3-none-any.whl (10.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.1/10.1 MB 3.3 MB/s eta 0:00:00
Requirement already satisfied: Kivy-Garden>=0.1.4 in ./kivyenv/lib/python3.12/site-packages (from kivy-examples) (0.1.5)
Requirement already satisfied: docutils in ./kivyenv/lib/python3.12/site-packages (from kivy-examples) (0.21.2)
Requirement already satisfied: pygments in ./kivyenv/lib/python3.12/site-packages (from kivy-examples) (2.18.0)
Requirement already satisfied: requests in ./kivyenv/lib/python3.12/site-packages (from Kivy-Garden>=0.1.4->kivy-examples) (2.32.3)
Requirement already satisfied: charset-normalizer<4,>=2 in ./kivyenv/lib/python3.12/site-packages (from requests->Kivy-Garden>=0.1.4->kivy-examples) (3.4.0)
Requirement already satisfied: idna<4,>=2.5 in ./kivyenv/lib/python3.12/site-packages (from requests->Kivy-Garden>=0.1.4->kivy-examples) (3.10)
Requirement already satisfied: urllib3<3,>=1.21.1 in ./kivyenv/lib/python3.12/site-packages (from requests->Kivy-Garden>=0.1.4->kivy-examples) (2.2.3)
Requirement already satisfied: certifi>=2017.4.17 in ./kivyenv/lib/python3.12/site-packages (from requests->Kivy-Garden>=0.1.4->kivy-examples) (2024.8.30)
Installing collected packages: kivy-examples
Successfully installed kivy-examples-2.3.0
–