From kivy app import app выдает ошибку

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

from kivy.app import App  

enter image description here

asked Mar 11, 2017 at 20:46

red5pider's user avatar

4

enter image description here

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)

Community's user avatar

answered Mar 11, 2017 at 21:08

kennytm's user avatar

kennytmkennytm

508k105 gold badges1078 silver badges1003 bronze badges

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.

answered Jun 27, 2018 at 19:27

Ric413's user avatar

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:Python34sharekivy-examplesanimation

  5. Save all your files in this folder.

gre_gor's user avatar

gre_gor

6,6129 gold badges45 silver badges52 bronze badges

answered Jun 21, 2017 at 14:50

chili17's user avatar

1

Kirya002

0 / 0 / 0

Регистрация: 03.02.2017

Сообщений: 53

1

07.05.2017, 17:16. Показов 8679. Ответов 9

Метки нет (Все метки)


Студворк — интернет-сервис помощи студентам

Решил освоить kivy app,установил через pip первые,вторые и третье указания.Вот код:

Python
1
2
3
4
5
6
7
8
import kivy
from kivy.app import App
 
class TutorialApp(App):
    pass
 
if __name__ == "__main__":
    TutorialApp().run()

А вот,что у меня высвечивается:

Python
1
2
3
4
Traceback (most recent call last):
  File "D:main1.py", line 2, in <module>
    from kivy.app import App
ImportError: No module named 'kivy.app'

Скажите,как мне исправить эту ошибку?Вот ссылка на kivy:https://kivy.org/docs/installa… ndows.html



0



Эксперт по компьютерным сетям

5889 / 3347 / 1033

Регистрация: 03.11.2009

Сообщений: 9,974

07.05.2017, 18:11

2

Ну как говорится — одно из трех — или Вы не установили киви, или установили, но запускаете другим питоном.



0



0 / 0 / 0

Регистрация: 03.02.2017

Сообщений: 53

07.05.2017, 18:33

 [ТС]

3

Я пытался установить через pip установив перед этим cython и pygame,но вот что вышло и ошибка не исправилась:http://softport02.ulcraft.com/… 995472.png
Как мне установить полностью kivy?



0



103 / 81 / 54

Регистрация: 25.11.2016

Сообщений: 278

07.05.2017, 19:44

4

Скорее всего у вас не установлен Microsoft Visual C++



0



Kirya002

0 / 0 / 0

Регистрация: 03.02.2017

Сообщений: 53

07.05.2017, 20:49

 [ТС]

7

У меня python35 win32.

Добавлено через 12 минут
Я попытался,но опять высвечивается ошибка:http://softport02.ulcraft.com/… c1fd81.png
(Возможно что-то в версии)

Добавлено через 8 минут
И так,вроде бы установил.Нашел в большой библиотеке(версия kivy не совпадала 1.9.2 заменил на 1.9.1).Вот ссылка:http://www.lfd.uci.edu/~gohlke/pythonlibs/
И так,а теперь вот,что получилось теперь.Код остается прежним,а вот сама ошибка другая.Вот ошибка:

Python
1
2
3
4
5
6
7
8
9
[WARNING           ] [Config      ] Older configuration version detected (0 instead of 14)
[WARNING           ] [Config      ] Upgrading configuration in progress.
[INFO              ] [Logger      ] Record log in C:UsersAdmin.kivylogskivy_17-05-07_0.txt
[INFO              ] [Kivy        ] v1.9.1
[INFO              ] [Python      ] v3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:16:59) [MSC v.1900 32 bit (Intel)]
 Traceback (most recent call last):
   File "D:main1.py", line 3, in <module>
     class TutorialApp(App):
 NameError: name 'App' is not defined

Скажите,как мне ее исправить?



0



Jabbson

Эксперт по компьютерным сетям

5889 / 3347 / 1033

Регистрация: 03.11.2009

Сообщений: 9,974

07.05.2017, 21:59

8

импорты точно не ушли никуда?

Добавлено через 1 минуту
а именно

Python
1
from kivy.app import App



0



0 / 0 / 0

Регистрация: 03.02.2017

Сообщений: 53

08.05.2017, 10:05

 [ТС]

9

Ну да,все так и осталось.

Добавлено через 6 минут
А нет,все работает.Просто надо было установить через whl.



0



10 / 9 / 3

Регистрация: 10.06.2013

Сообщений: 486

11.08.2021, 00:28

10

У меня похожая ошибка

Traceback (most recent call last):
File «C:/src3/main.py», line 15, in <module>
from kivy.uix.button import Button
ModuleNotFoundError: No module named ‘kivy’



0



IT_Exp

Эксперт

87844 / 49110 / 22898

Регистрация: 17.06.2006

Сообщений: 92,604

11.08.2021, 00:28

10

Software Versions

  • Python: 3.9.0
  • OS: Windows 10
  • Kivy: 2.0.0rc4
  • Kivy installation method: Conda

Describe the bug
After installing Kivy using official documentation, Kivy fails to import.

Anaconda Prompt output:

(base) C:Usersmikolas>conda install kivy -c conda-forge
Collecting package metadata (current_repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.8.3
  latest version: 4.9.2

Please update conda by running

    $ conda update -n base -c defaults conda



## Package Plan ##

  environment location: C:Usersmikolasminiconda3

  added / updated specs:
    - kivy


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    ca-certificates-2020.11.8  |       h5b45459_0         183 KB  conda-forge
    certifi-2020.11.8          |   py38haa244fe_0         150 KB  conda-forge
    conda-4.9.2                |   py38haa244fe_0         3.1 MB  conda-forge
    docutils-0.16              |   py38h9bdc248_2         745 KB  conda-forge
    freetype-2.10.4            |       h546665d_0         493 KB  conda-forge
    glew-2.1.0                 |       he025d50_0         824 KB  conda-forge
    jpeg-9d                    |       h8ffe710_0         366 KB  conda-forge
    kivy-2.0.0rc4              |   py38h7600b87_2        19.9 MB  conda-forge
    libpng-1.6.37              |       h1d00b33_2         724 KB  conda-forge
    libtiff-4.1.0              |       hc10be44_6         1.1 MB  conda-forge
    libwebp-1.0.2              |       hfa6e2cd_5         356 KB  conda-forge
    lz4-c-1.9.2                |       h62dcd97_2         279 KB  conda-forge
    olefile-0.46               |     pyh9f0ad1d_1          32 KB  conda-forge
    openssl-1.1.1h             |       he774522_0         5.8 MB  conda-forge
    pillow-8.0.1               |   py38hd8d9125_0         754 KB  conda-forge
    pygments-2.7.2             |             py_0         707 KB  conda-forge
    python_abi-3.8             |           1_cp38           4 KB  conda-forge
    sdl2-2.0.12                |       h0e60522_1         1.8 MB  conda-forge
    sdl2_image-2.0.5           |       hb9708c9_2         213 KB  conda-forge
    sdl2_mixer-2.0.4           |       h6538335_0          83 KB  conda-forge
    sdl2_ttf-2.0.15            |       h4636d2b_0          26 KB  conda-forge
    smpeg2-2.0.0               |       h6538335_1         131 KB  conda-forge
    tk-8.6.10                  |       he774522_1         3.2 MB  conda-forge
    xz-5.2.5                   |       h62dcd97_1         211 KB  conda-forge
    zstd-1.4.5                 |       h1f3a1b7_2         887 KB  conda-forge
    ------------------------------------------------------------
                                           Total:        41.8 MB

The following NEW packages will be INSTALLED:

  docutils           conda-forge/win-64::docutils-0.16-py38h9bdc248_2
  freetype           conda-forge/win-64::freetype-2.10.4-h546665d_0
  glew               conda-forge/win-64::glew-2.1.0-he025d50_0
  jpeg               conda-forge/win-64::jpeg-9d-h8ffe710_0
  kivy               conda-forge/win-64::kivy-2.0.0rc4-py38h7600b87_2
  libpng             conda-forge/win-64::libpng-1.6.37-h1d00b33_2
  libtiff            conda-forge/win-64::libtiff-4.1.0-hc10be44_6
  libwebp            conda-forge/win-64::libwebp-1.0.2-hfa6e2cd_5
  lz4-c              conda-forge/win-64::lz4-c-1.9.2-h62dcd97_2
  olefile            conda-forge/noarch::olefile-0.46-pyh9f0ad1d_1
  pillow             conda-forge/win-64::pillow-8.0.1-py38hd8d9125_0
  pygments           conda-forge/noarch::pygments-2.7.2-py_0
  python_abi         conda-forge/win-64::python_abi-3.8-1_cp38
  sdl2               conda-forge/win-64::sdl2-2.0.12-h0e60522_1
  sdl2_image         conda-forge/win-64::sdl2_image-2.0.5-hb9708c9_2
  sdl2_mixer         conda-forge/win-64::sdl2_mixer-2.0.4-h6538335_0
  sdl2_ttf           conda-forge/win-64::sdl2_ttf-2.0.15-h4636d2b_0
  smpeg2             conda-forge/win-64::smpeg2-2.0.0-h6538335_1
  tk                 conda-forge/win-64::tk-8.6.10-he774522_1
  xz                 conda-forge/win-64::xz-5.2.5-h62dcd97_1
  zstd               conda-forge/win-64::zstd-1.4.5-h1f3a1b7_2

The following packages will be UPDATED:

  ca-certificates     pkgs/main::ca-certificates-2020.1.1-0 --> conda-forge::ca-certificates-2020.11.8-h5b45459_0
  certifi              pkgs/main::certifi-2020.4.5.1-py38_0 --> conda-forge::certifi-2020.11.8-py38haa244fe_0
  conda                       pkgs/main::conda-4.8.3-py38_0 --> conda-forge::conda-4.9.2-py38haa244fe_0
  openssl              pkgs/main::openssl-1.1.1g-he774522_0 --> conda-forge::openssl-1.1.1h-he774522_0


Proceed ([y]/n)?


Downloading and Extracting Packages
zstd-1.4.5           | 887 KB    | ############################################################################ | 100%
sdl2_mixer-2.0.4     | 83 KB     | ############################################################################ | 100%
pygments-2.7.2       | 707 KB    | ############################################################################ | 100%
certifi-2020.11.8    | 150 KB    | ############################################################################ | 100%
glew-2.1.0           | 824 KB    | ############################################################################ | 100%
docutils-0.16        | 745 KB    | ############################################################################ | 100%
sdl2_ttf-2.0.15      | 26 KB     | ############################################################################ | 100%
xz-5.2.5             | 211 KB    | ############################################################################ | 100%
sdl2_image-2.0.5     | 213 KB    | ############################################################################ | 100%
freetype-2.10.4      | 493 KB    | ############################################################################ | 100%
sdl2-2.0.12          | 1.8 MB    | ############################################################################ | 100%
libwebp-1.0.2        | 356 KB    | ############################################################################ | 100%
lz4-c-1.9.2          | 279 KB    | ############################################################################ | 100%
olefile-0.46         | 32 KB     | ############################################################################ | 100%
jpeg-9d              | 366 KB    | ############################################################################ | 100%
libtiff-4.1.0        | 1.1 MB    | ############################################################################ | 100%
pillow-8.0.1         | 754 KB    | ############################################################################ | 100%
kivy-2.0.0rc4        | 19.9 MB   | ############################################################################ | 100%
ca-certificates-2020 | 183 KB    | ############################################################################ | 100%
tk-8.6.10            | 3.2 MB    | ############################################################################ | 100%
libpng-1.6.37        | 724 KB    | ############################################################################ | 100%
conda-4.9.2          | 3.1 MB    | ############################################################################ | 100%
python_abi-3.8       | 4 KB      | ############################################################################ | 100%
openssl-1.1.1h       | 5.8 MB    | ############################################################################ | 100%
smpeg2-2.0.0         | 131 KB    | ############################################################################ | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

After installation I continued with official Pong Game Tutorial, but after running this code:

from kivy.app import App
from kivy.uix.widget import Widget


class PongGame(Widget):
    pass


class PongApp(App):
    def build(self):
        return PongGame()


if __name__ == '__main__':
    PongApp().run()

I got following error:

C:UsersmikolasProjectspong>python main.py
Traceback (most recent call last):
  File "C:UsersmikolasProjectspongmain.py", line 1, in <module>
    from kivy.app import App
ModuleNotFoundError: No module named 'kivy'

Expected behavior
I would expect official installation process and quickstart should actually work…

pycharm установлен. Как видите по скрину установлен и kivy644fa64b958f4339bb1984855b5bf04e.jpg
При import kivy никаких проблем но при командах типа
from kivy.app import App или
from kivy.uix.label import Label
выдает ошибки такого рода.

Traceback (most recent call last):
   File "C:/Users/Хачапури/PycharmProjects/untitled/test.py", line 1, in <module>
     from kivy.app import App
   File "C:Program Filespython34libsite-packageskivyapp.py", line 327, in <module>
     from kivy.uix.widget import Widget
   File "C:Program Filespython34libsite-packageskivyuixwidget.py", line 219, in <module>
     from kivy.graphics import (
   File "C:Program Filespython34libsite-packageskivygraphics__init__.py", line 89, in <module>
     from kivy.graphics.instructions import Callback, Canvas, CanvasBase, 
 ImportError: DLL load failed: Не найден указанный модуль.

Ошибки наводят на мысль, что киви не установлен. Но как так? Что я сделал не так?

Asked
3 years, 2 months ago

Viewed
304 times

Python kivy: cannot import name 'App' form 'kivy.app'

I’m new at kivy, and I follow all the instructions on the kivy documentation but still it shows me errors like this. I also watch and google a solution for this but it always throw me errors, do you have any solution for this? Thank you in advance.

  • python
  • python-3.x
  • user-interface
  • kivy
  • kivy-language

asked Apr 6, 2020 at 18:51

IAmKeyboard09219's user avatar

1

  • That error seems to indicate that Kivy is there, but app.py doesn’t contain an App class. I don’t know why that would be, it’s quite a strange problem given everything else seems to be in place.

    Apr 6, 2020 at 20:38

2 Answers

replace python.exe with pythonw.exe in your interpreter, this worked for me

answered Apr 7, 2020 at 18:27

Vinz's user avatar

VinzVinz

2401 silver badge9 bronze badges

answered Apr 7, 2020 at 20:36

Dragoș's user avatar

  • The Overflow Blog
  • Featured on Meta

Related

Hot Network Questions

  • Looking for some alternative branching strategies to meet my team’s needs

  • What are some conjectures of your own?

  • Looping area calculations for multiple rasters in R

  • Nonstandard game results

  • Move arrayed object towards centre

  • Why does voltage increase in a series circuit?

  • Is there a word that’s the relational opposite of «Childless»? (Specifically for when trying to categorize an adult)

  • Why did my papers get repeatedly put on the last day and the last session of a conference?

  • Exercise 3, Section 5 of Hungerford’s Abstract Algebra

  • What are the Star Trek episodes where the Captain lowers their shields as sign of trust?

  • Can existence be justified as ‘better’ than non-existence?

  • Help identifying an insect

  • Can the Wildfire Druid ability Blazing Revival prevent Instant Death due to massive damage or disintegrate?

  • False proofs that look correct

  • Plateau problem for fluxes of curves

  • Text-based Tic-Tac-Toe

  • What does «In a favorable time» mean in 2 Corinthians 6:2?

  • Is it true that the Chief Justice granted royal assent to the Online Streaming Act?

  • Garage door suddenly really heavy, opener gives up

  • Why are my strawberries shaped like this?

  • Paper with potentially inappropriately-ordered authors, should a journal act?

  • The magic number 376

  • Is ‘..’ really a hard link?

  • Can you aid and abet a crime against yourself?

more hot questions

Question feed

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Понравилась статья? Поделить с друзьями:
  • From flask import flask ошибка
  • Fprnm1c dll фискальный регистратор ошибка при подключении
  • Fprint 5200 ошибки в фп
  • Foxmail ошибка соединения ssl errorcode 5
  • From dust вылетает с ошибкой