ubuntu 18 下安装 kivy 以及解决ImportError: No module named 'kivy._clock'
系统 ubuntu 18.04 python 3.6.5
按照官方教程ubuntu 18.04 第一步添加ppa源时候 一定要选择nightly builds kivy官方指南
ubuntu 18.04 kivy 安装
1第一步添加ppa源(一定要选择 nightly builds 不然会出现 安装好了 No module named _clock 错误)nightly builds:$ sudo add-apt-repository ppa:kivy-team/kivy-daily
更新软件源头$ sudo apt-get update
2 安装Install KivyPython3 - python3-kivy:
$ sudo apt-get install python3-kivyoptionally the examples - kivy-examples: $ sudo apt-get install kivy-examples
3 添加kivy的依赖(python3 环境)
# Install necessary system packages
sudo apt-get install -y \ python-pip \ build-essential \ git \ python3 \ python3-dev \ ffmpeg \ libsdl2-dev \ libsdl2-image-dev \ libsdl2-mixer-dev \ libsdl2-ttf-dev \ libportmidi-dev \ libswscale-dev \ libavformat-dev \ libavcodec-dev \ zlib1g-dev
# 添加视频音频的依赖
# Install gstreamer for audio, video (optional)sudo apt-get install -y \ libgstreamer1.0 \ gstreamer1.0-plugins-base \ gstreamer1.0-plugins-good
根据教程安装 kivy 后出现ubuntu18 添加错误ppa源文件之后会出现无法引入kivy包
File "main.py", line 3, infrom kivy.app import App File "/usr/local/lib/python3.5/dist-packages/kivy/app.py", line 319, infrom kivy.base import runTouchApp, stopTouchApp File "/usr/local/lib/python3.5/dist-packages/kivy/base.py", line 29, infrom kivy.clock import Clock File "/usr/local/lib/python3.5/dist-packages/kivy/clock.py", line 234, in from kivy._clock import CyClockBase, ClockEvent
ImportError: No module named 'kivy._clock'
解决方法如下
- 删除原来的kivy 的ppa源
win键 --> 软件和更新(soft&update)--> 其他软件 -->删除stable builds的ppa源
http://ppa.launchpad.net/kivy-team/kivy/ubuntu xenial main
-
卸载当前环境的kivy
sudo apt-get remove python-kivy
sudo apt-get remove python3-kivy
-
安装night builds
sudo add-apt-repository ppa:kivy-team/kivy-daily
重启系统(不重启不知道有用没 反正我重启了)
重新安装kivy(见文章开头)
参考
Kivy 1.10.1 on pycharm ubuntu18:
ImportError: No module named _clock
ImportError: No module named _clock
@MichaelJames02 This can also happen when there's a system installation (e.g. from the PPA) and a local copy (e.g. git clone ...).
For Ubuntu 18.04 I recommend using the daily PPA right now, and make sure your working directory doesn't have a copy of Kivy.
If the problem still persists, please open a new issue with all the details of your setup, instead of commenting on an old one.