简体   繁体   中英

Kivy, ImportError: cannot import name App

everything was working fine on my ubuntu machine and suddenly i can't import App from kivy.app

from kivy.app import App  

在此输入图像描述

在此输入图像描述

One of Kivy's internal module weakmethod.py is trying to import another internal module new.py . But you have create a new.py next to where you run python, so Python will try to load yours first. This breaks everything because weakmethod doesn't expect that your new.py , it wants the internal new.py !. The solution is to rename this offending file.

(The actual problem causing ImportError is circular import on the kivy.app module)

For me, the import error "cannot import name app" was syntax. I replaced app with App and that solved my problem. I was able to re-create, and resolve the issue, by changing the case from lower to upper and vise versa.

Follow this procedure:

  1. Go to kivy website

  2. Go to -> download -> Windows 7, 8, 10 (32/64 bit) Install using pip, follow the instructions here -> installation for Windows

  3. Copy and pasted in CMD-> python -m pip install kivy_examples --> (The examples are installed in the share directory under the root directory where python is installed)

  4. For example C:\\Python34\\share\\kivy-examples\\animation

  5. Save all your files in this folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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