简体   繁体   English

kivy 和 python3 在 ubuntu 18.04 上不起作用

[英]kivy and python3 doesnt work on ubuntu 18.04

I have laptop with ubuntu 18.04 and i use for programming in python3.我有带 ubuntu 18.04 的笔记本电脑,我用于在 python3 中编程。 I decided to learn how i can make GUI and i chosen Kivy because of its multi-platform feature.我决定学习如何制作 GUI 并选择 Kivy,因为它具有多平台功能。 After adding Kivy ppa and installing python3-kivy package with apt i tried to test the simple example with one button in the first page of kivy.org but it return this errors:在添加 Kivy ppa 并使用 apt 安装 python3-kivy 包后,我尝试使用 kivy.org 第一页中的一个按钮测试简单示例,但它返回以下错误:

screenshot from my terminal我的终端截图

after that i installed python-kivy package for python2 and run this test file again but this time there is no problem and the GUI showed correctly.之后我为python2安装了python-kivy包并再次运行这个测试文件,但这次没有问题并且GUI显示正确。

the program runs correctly程序运行正常

now i can use python2 but i always use python3 before and i want to use it with kivy.现在我可以使用 python2,但我以前总是使用 python3,我想和 kivy 一起使用它。 Can anyone tell me why this problem happens?谁能告诉我为什么会出现这个问题?

Solution for me was, with Python 3.6.5我的解决方案是,使用 Python 3.6.5

Uninstall everything:卸载一切:

sudo apt-get remove --purge python3-kivy
sudo pip3 uninstall cython kivy
sudo apt autoremove

Then:然后:

sudo pip3 install Cython==0.28.2
sudo pip3 install https://github.com/kivy/kivy/archive/master.zip

or in case you need version 1.9.1或者如果您需要 1.9.1 版

sudo pip3 install Cython==0.23
sudo pip3 install kivy==1.9.1

This bug, which I confirmed in Ubuntu 18.04, is probably the reason why python3-kivy was dropped from the default Ubuntu repositories in Ubuntu 19.04.我在 Ubuntu 18.04 中确认的这个错误可能是 python3-kivy 从 Ubuntu 19.04 的默认 Ubuntu 存储库中删除的原因。 This bug has been fixed and python3-kivy has been restored to the default Ubuntu repositories in Ubuntu 19.10 and later.此错误已修复,python3-kivy 已恢复到 Ubuntu 19.10 及更高版本中的默认 Ubuntu 存储库。

A later version of Kivy 1.11.1 (instead of 1.9.1 in Ubuntu 18.04) can be installed with python3 -m pip install kivy in a Python virtual environment using Python 3 virtual environment creator ( python3-virtualenv ) from the default Ubuntu repositories. Kivy 1.11.1 的更高版本(而不是 Ubuntu 18.04 中的 1.9.1)可以使用python3 -m pip install kivyPython 虚拟环境中,使用 Python 3 虚拟环境创建器 ( python3-virtualenv ) 从默认 Ubuntu 存储库中。 Try running python3 -m pip install --upgrade pip before python3 -m pip install kivy to upgrade your pip3 to the latest version as I did.尝试运行python3 -m pip install --upgrade pip之前python3 -m pip install kivy像我一样你PIP3升级到最新版本。

Below are the results of running this Hello World test program with Kivy 1.11.1 in a Python 3 virtual environment.下面是在 Python 3 虚拟环境中使用 Kivy 1.11.1 运行这个Hello World 测试程序的结果。 The Python 3 code ran without any errors, detected OpenGL and my NVIDIA proprietary graphics driver, and output this window: Python 3 代码运行没有任何错误,检测到 OpenGL 和我的 NVIDIA 专有图形驱动程序,并输出以下窗口:

在此处输入图片说明

Note that at this time the support for android python3 kivy is experimental.请注意,此时对 android python3 kivy 的支持是实验性的。 Even though you may create the .apk chances are it will not work.即使您可能会创建 .apk,它也可能不起作用。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM