Partage
  • Partager sur Facebook
  • Partager sur Twitter

Problème lors de l'importation d'un module kivy.

Problème lors de l'importation d'un module kivy.

    30 octobre 2017 à 19:19:39

    Bonjour à tous,

    J'ai installé kivy et je suis allé dans la documentation pour faire des tests.

    J'ai essayé d'importer le module Button:

    from kivy.uix import button

    Mais la fenêtre s'est fermé directement après.

    Si vous avez des solutions, merci de m'en faire part.

    • Partager sur Facebook
    • Partager sur Twitter
    Anonyme
      30 octobre 2017 à 19:41:45

      Si tu mets une pause ça évitera sans doute de quitter la fenêtre lors de la fin du programme.
      • Partager sur Facebook
      • Partager sur Twitter
        30 octobre 2017 à 20:43:56

        Il faut juste lancer ton code depuis une console (et non en cliquant dessus). Sinon tu ne verras jamais les messages d'erreurs.

        L'objet Button (avec une majuscule) se trouve dans le fichier button:

        from kivy.uix.button import Button
        • Partager sur Facebook
        • Partager sur Twitter
        Précepte: Le mieux est l'ennemi du bien
          31 octobre 2017 à 11:46:37

          J'ai mis en pause le programme mais il s'est quand même fermé.

          Sinon je l'ai lancé sur la console python mais ça a fait pareil...

          • Partager sur Facebook
          • Partager sur Twitter
            31 octobre 2017 à 18:12:24

            Que t'attends tu a avoir? importer un module n'a pas grand effet, un programme kivy minimum serait plutôt

            from kivy.uix.button import Button
            
            from kivy.app import App
            
            
            class ButtonApp(App):
            
                 def build(self):
            
                    return Button(text='click me', on_press=self.hello)
            
            
                 def hello(self, *args):
            
                     print("hello")
            
            
            if __name__ == '__main__':
            
                ButtonApp().run()
            


            -
            Edité par gabrielpettier 31 octobre 2017 à 18:12:42

            • Partager sur Facebook
            • Partager sur Twitter
              31 octobre 2017 à 20:05:31

              Tymo2 a écrit:

              Sinon je l'ai lancé sur la console python mais ça a fait pareil...


              Pas dans la console python, mais dans la console de ton ordi (cmd sur windows, Terminal sur mac). Ça fera assurément pas pareil car ça te permettra de voir le message d'erreur.
              • Partager sur Facebook
              • Partager sur Twitter
              Précepte: Le mieux est l'ennemi du bien
                4 novembre 2017 à 11:11:46

                Bonjour

                -
                Edité par PierreBousselin 4 novembre 2017 à 11:12:54

                • Partager sur Facebook
                • Partager sur Twitter
                  4 novembre 2017 à 11:16:37

                  Je l'ai lancé avec PowerShell:

                  >>> from kivy.uix.button import Button
                  [INFO   ] [Logger      ] Record log in C:\Users\B06973\.kivy\logs\kivy_17-11-04_2.txt
                  [INFO   ] [Kivy        ] v1.10.0
                  [INFO   ] [Python      ] v3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 17:26:49) [MSC v.1900 32 bit (Intel)]
                  [INFO   ] [Factory     ] 194 symbols loaded
                  [INFO   ] [Image       ] Providers: img_tex, img_dds, img_gif (img_sdl2, img_pil, img_ffpyplayer ignored)
                  [CRITICAL] [Text        ] Unable to find any valuable Text provider.
                  sdl2 - ImportError: DLL load failed: The specified module could not be found.
                    File "C:\Users\B06973\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\__init__.py", line 59, in
                  core_select_lib
                      fromlist=[modulename], level=0)
                    File "C:\Users\B06973\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\text\text_sdl2.py", line 1
                  2, in <module>
                      from kivy.core.text._text_sdl2 import (_SurfaceContainer, _get_extents,
                  
                  pil - ModuleNotFoundError: No module named 'PIL'
                    File "C:\Users\B06973\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\__init__.py", line 59, in
                  core_select_lib
                      fromlist=[modulename], level=0)
                    File "C:\Users\B06973\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\text\text_pil.py", line 7,
                   in <module>
                      from PIL import Image, ImageFont, ImageDraw
                  
                  [CRITICAL] [App         ] Unable to get a Text provider, abort.

                  Apparemment le module ne peut pas être trouvé...(ImportError)



                  -
                  Edité par Tymo2 5 novembre 2017 à 11:45:12

                  • Partager sur Facebook
                  • Partager sur Twitter
                    10 novembre 2017 à 23:03:29

                    Apparemment c'est un problème d'installation du module PIL (ligne 16). Il faut donc l'installer (car c'est un module externe). Ce module n'est plus à jour (il me semble) et a été remplacé par le module Pillow (donc c'est lui que tu dois installer). Normalement, la commande suivante devrait installer le module (à écrire dans l'invite de commande et non dans l'interpréteur python):

                    pip install Pillow
                    • Partager sur Facebook
                    • Partager sur Twitter
                    Précepte: Le mieux est l'ennemi du bien
                      11 novembre 2017 à 19:11:37

                      Finalement j'ai trouvé la solution sur un autre forum, merci de vos aides

                      -
                      Edité par Tymo2 12 novembre 2017 à 18:16:19

                      • Partager sur Facebook
                      • Partager sur Twitter
                        15 novembre 2017 à 19:53:58

                        J'ai en effet bien réussi à importer le module, mais dès que je l'utilise, il y a une erreur:

                        >>> variable=Button(text="hello",fonte_size=11)
                        [CRITICAL] [Window      ] Unable to find any valuable Window provider.
                        sdl2 - ImportError: DLL load failed: The specified module could not be found.
                          File "C:\Users\B06973\AppData\Local\Programs\Python\Python36-32\lib\site-packa
                        ges\kivy\core\__init__.py", line 59, in core_select_lib
                            fromlist=[modulename], level=0)
                          File "C:\Users\B06973\AppData\Local\Programs\Python\Python36-32\lib\site-packa
                        ges\kivy\core\window\window_sdl2.py", line 26, in <module>
                            from kivy.core.window._window_sdl2 import _WindowSDL2Storage
                        
                        [CRITICAL] [App         ] Unable to get a Window, abort.
                         Exception ignored in: 'kivy.properties.dpi2px'
                         Traceback (most recent call last):
                           File "C:\Users\B06973\AppData\Local\Programs\Python\Python36-32\lib\site-pack
                        ages\kivy\utils.py", line 496, in __get__
                             retval = self.func(inst)
                           File "C:\Users\B06973\AppData\Local\Programs\Python\Python36-32\lib\site-pack
                        ages\kivy\metrics.py", line 174, in dpi
                             EventLoop.ensure_window()
                           File "C:\Users\B06973\AppData\Local\Programs\Python\Python36-32\lib\site-pack
                        ages\kivy\base.py", line 127, in ensure_window
                             sys.exit(1)
                         SystemExit: 1
                        [CRITICAL] [App         ] Unable to get a Window, abort.


                        Merci de vos aides.

                        • Partager sur Facebook
                        • Partager sur Twitter
                          24 novembre 2017 à 19:47:09

                          J'ai installé sdl2 mais il y a une autre erreur avec les fichiers et j'y comprend plus rien...

                          >>> button=Button(text="test",fonte_size=14)
                          [INFO   ] [OSC         ] using <thread> for socket
                          [INFO   ] [Window      ] Provider: sdl2
                          [INFO   ] [GL          ] Using the "OpenGL" graphics system
                          [INFO   ] [GL          ] GLEW initialization succeeded
                          [INFO   ] [GL          ] Backend used <glew>
                          [INFO   ] [GL          ] OpenGL version <b'4.2.0 - Build 10.18.10.3574'>
                          [INFO   ] [GL          ] OpenGL vendor <b'Intel'>
                          [INFO   ] [GL          ] OpenGL renderer <b'Intel(R) HD Graphics 4400'>
                          [INFO   ] [GL          ] OpenGL parsed version: 4, 2
                          [INFO   ] [GL          ] Shading version <b'4.20 - Build 10.18.10.3574'>
                          [INFO   ] [GL          ] Texture max size <16384>
                          [INFO   ] [GL          ] Texture max units <32>
                          [INFO   ] [Window      ] auto add sdl2 input provider
                          [INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
                           Traceback (most recent call last):
                             File "<stdin>", line 1, in <module>
                             File "C:\Users\B06973\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\uix\behaviors\button.py", line
                           121, in __init__
                               super(ButtonBehavior, self).__init__(**kwargs)
                             File "C:\Users\B06973\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\uix\label.py", line 277, in __
                          init__
                               super(Label, self).__init__(**kwargs)
                             File "C:\Users\B06973\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\uix\widget.py", line 337, in _
                          _init__
                               super(Widget, self).__init__(**kwargs)
                             File "kivy\_event.pyx", line 254, in kivy._event.EventDispatcher.__init__ (kivy\_event.c:5332)
                           TypeError: object.__init__() takes no parameters



                          -
                          Edité par Tymo2 24 novembre 2017 à 19:47:38

                          • Partager sur Facebook
                          • Partager sur Twitter
                            25 novembre 2017 à 21:19:26

                            Bonjours je en train de bosser avec matplotlib mais quand je l'installe il me fait le caprice suivant :

                            pip install -r requirements.txt
                            Requirement already satisfied: pandas in c:\users\sophie\desktop\perfectionnez_vous_en_python-p2c1\env\lib\site-packages (from -r requirements.txt (line 1))
                            Collecting matplotlib (from -r requirements.txt (line 2))
                              Using cached matplotlib-2.1.0.tar.gz
                                Complete output from command python setup.py egg_info:
                                ============================================================================
                                Edit setup.cfg to change the build options
                            
                                BUILDING MATPLOTLIB
                                            matplotlib: yes [2.1.0]
                                                python: yes [3.7.0a2 (v3.7.0a2:f7ac4fe, Oct 17 2017,
                                                        17:06:29) [MSC v.1900 64 bit (AMD64)]]
                                              platform: yes [win32]
                            
                                REQUIRED DEPENDENCIES AND EXTENSIONS
                                                 numpy: yes [version 1.13.3]
                                                   six: yes [using six version 1.11.0]
                                              dateutil: yes [using dateutil version 2.6.1]
                                backports.functools_lru_cache: yes [Not required]
                                          subprocess32: yes [Not required]
                                                  pytz: yes [using pytz version 2017.3]
                                                cycler: yes [cycler was not found. pip/easy_install may
                                                        attempt to install it after matplotlib.]
                                               tornado: yes [tornado was not found. It is required for the
                                                        WebAgg backend. pip/easy_install may attempt to
                                                        install it after matplotlib.]
                                             pyparsing: yes [pyparsing was not found. It is required for
                                                        mathtext support. pip/easy_install may attempt to
                                                        install it after matplotlib.]
                                                libagg: yes [pkg-config information for 'libagg' could not
                                                        be found. Using local copy.]
                                              freetype: no  [The C/C++ header for freetype
                                                        (freetype2\ft2build.h) could not be found.  You may
                                                        need to install the development package.]
                                                   png: no  [The C/C++ header for png (png.h) could not be
                                                        found.  You may need to install the development
                                                        package.]
                                                 qhull: yes [pkg-config information for 'libqhull' could not
                                                        be found. Using local copy.]
                            
                                OPTIONAL SUBPACKAGES
                                           sample_data: yes [installing]
                                              toolkits: yes [installing]
                                                 tests: no  [skipping due to configuration]
                                        toolkits_tests: no  [skipping due to configuration]
                            
                                OPTIONAL BACKEND EXTENSIONS
                                                macosx: no  [Mac OS-X only]
                                                qt5agg: no  [PySide2 not found; PyQt5 not found]
                                                qt4agg: no  [PySide not found; PyQt4 not found]
                                               gtk3agg: no  [Requires pygobject to be installed.]
                                             gtk3cairo: no  [Requires cairocffi or pycairo to be installed.]
                                                gtkagg: no  [Requires pygtk]
                                                 tkagg: yes [installing; run-time loading from Python Tcl /
                                                        Tk]
                                                 wxagg: no  [requires wxPython]
                                                   gtk: no  [Requires pygtk]
                                                   agg: yes [installing]
                                                 cairo: no  [cairocffi or pycairo not found]
                                             windowing: yes [installing]
                            
                                OPTIONAL LATEX DEPENDENCIES
                                                dvipng: no
                                           ghostscript: no
                                                 latex: no
                                               pdftops: no
                            
                                OPTIONAL PACKAGE DATA
                                                  dlls: no  [skipping due to configuration]
                            
                                ============================================================================
                                                        * The following required packages can not be built:
                                                        * freetype, png * Please check http://gnuwin32.sourc
                                                        * eforge.net/packages/freetype.htm for instructions
                                                        * to install freetype * Please check http://gnuwin32
                                                        * .sourceforge.net/packages/libpng.htm for
                                                        * instructions to install png
                            
                                ----------------------------------------
                            Command "python setup.py egg_info" failed with error code 1 in C:\Users\Sophie\AppData\Local\Temp\pip-build-o5xjqv0h\matplotlib\


                            • Partager sur Facebook
                            • Partager sur Twitter

                            Problème lors de l'importation d'un module kivy.

                            × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
                            × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
                            • Editeur
                            • Markdown