Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentError: argument 3: <class 'TypeError'>: wrong type #6428

Closed
bailong8281566 opened this issue Jul 20, 2019 · 12 comments
Closed

ArgumentError: argument 3: <class 'TypeError'>: wrong type #6428

bailong8281566 opened this issue Jul 20, 2019 · 12 comments
Labels
FAQ Issues that we need to document in a FAQ

Comments

@bailong8281566
Copy link

Issue
I test the kivy code by Miniconda3(also test it in Anaconda3,the same issus appeard),
Every time I press F5 for the first time, the code runs normally,and kivy interface appears normally, as follow:

runfile('C:/Users/38477/.spyder-py3/temp.py', wdir='C:/Users/38477/.spyder-py3')
[INFO   ] [Logger      ] Record log in C:\Users\38477\.kivy\logs\kivy_19-07-20_1.txt
[INFO   ] [Kivy        ] v1.11.1
[INFO   ] [Kivy        ] Installed at "G:\Miniconda3\lib\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "G:\Miniconda3\pythonw.exe"
[INFO   ] [Factory     ] 184 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
[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.0.0 - Build 10.18.10.4885'>
[INFO   ] [GL          ] OpenGL vendor <b'Intel'>
[INFO   ] [GL          ] OpenGL renderer <b'Intel(R) HD Graphics 4000'>
[INFO   ] [GL          ] OpenGL parsed version: 4, 0
[INFO   ] [GL          ] Shading version <b'4.00 - Build 10.18.10.4885'>
[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <16>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO   ] [Base        ] Start application main loop
[INFO   ] [GL          ] NPOT texture support is available
[INFO   ] [WindowSDL   ] exiting mainloop and closing.
[INFO   ] [Base        ] Leaving application in progress...

but after colsing kivy interface ,pressing F5 will report the following error.

runfile('C:/Users/38477/.spyder-py3/temp.py', wdir='C:/Users/38477/.spyder-py3')
[INFO   ] [Base        ] Start application main loop
[ERROR  ] [Base        ] No event listeners have been created
[ERROR  ] [Base        ] Application will leave
[INFO   ] [Base        ] Leaving application in progress...
[INFO   ] [Base        ] Leaving application in progress...
Traceback (most recent call last):

 File "<ipython-input-2-83710e3ec7f9>", line 1, in <module>
   runfile('C:/Users/38477/.spyder-py3/temp.py', wdir='C:/Users/38477/.spyder-py3')

 File "G:\Miniconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
   execfile(filename, namespace)

 File "G:\Miniconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
   exec(compile(f.read(), filename, 'exec'), namespace)

 File "C:/Users/38477/.spyder-py3/temp.py", line 15, in <module>
   TestApp().run()

 File "G:\Miniconda3\lib\site-packages\kivy\app.py", line 855, in run
   runTouchApp()

 File "G:\Miniconda3\lib\site-packages\kivy\base.py", line 506, in runTouchApp
   stopTouchApp()

 File "G:\Miniconda3\lib\site-packages\kivy\base.py", line 521, in stopTouchApp
   EventLoop.close()

 File "G:\Miniconda3\lib\site-packages\kivy\base.py", line 172, in close
   self.stop()

 File "G:\Miniconda3\lib\site-packages\kivy\base.py", line 184, in stop
   provider.stop()

 File "G:\Miniconda3\lib\site-packages\kivy\input\providers\wm_pen.py", line 111, in stop
   SetWindowLong_WndProc_wrapper(self.hwnd, self.old_windProc)

 File "G:\Miniconda3\lib\site-packages\kivy\input\providers\wm_common.py", line 122, in _closure
   oldAddr = func(hWnd, GWL_WNDPROC, cast(wndProc, c_void_p).value)

ArgumentError: argument 3: <class 'TypeError'>: wrong type

Restart the kernel is a feasible method, but this means that I must restart the kernel every time after runing the code. Is is normal?

Environment

active environment : base
active env location : G:\Miniconda3
shell level : 1
user config file : C:\Users\38477\.condarc
populated config files :
conda version : 4.7.9
conda-build version : not installed
python version : 3.7.3.final.0
virtual packages : __cuda=9.1
base environment : G:\Miniconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
 package cache : G:\Miniconda3\pkgs
                           C:\Users\38477\.conda\pkgs
                          C:\Users\38477\AppData\Local\conda\conda\pkgs
       envs directories : G:\Miniconda3\envs
                          C:\Users\38477\.conda\envs
                          C:\Users\38477\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/4.7.9 requests/2.21.0 CPython/3.7.3 Windows/10 Windows/10.0.17134
administrator : False
netrc file : None
offline mode : False

here is the test code I got from https://kivy.org/#home

from kivy.app import App
from kivy.uix.button import Button

class TestApp(App):
    def build(self):
        return Button(text='Hello World')

TestApp().run()
@matham
Copy link
Member

matham commented Jul 21, 2019

F5 doesn't do anything for kivy so I'm not sure what you mean. Do you mean pressing F5 in spyder? I can't really help you with spyder as I don't use it.

Are you trying to run kivy multiple times within the same python execution? Normally you need to restart python if you want to run kivy multiple times because kivy is meant to be run as an app that starts fresh every time it is run. There are ways to have kivy clean up after itself, but those are not officially documented.

@matham matham added the awaiting-reply Waiting for reply from issue opener, will be closed if no reply label Jul 21, 2019
@no-response
Copy link

no-response bot commented Aug 4, 2019

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have the means to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@no-response no-response bot closed this as completed Aug 4, 2019
@iamworldlywise
Copy link

I was facing the same issue. Finally solved it by executing the code in external terminal.
Go to tools>preferences>run>execute in an external system terminal and then click ok.

@0xForp
Copy link

0xForp commented Nov 6, 2019

I had the same issue trying to run with Jupyter Notebook and Pycharm...
I managed to open it with Spyder.

@scorpiotonytw
Copy link

I was facing the same issue with Spyder. The solution is Go to Consoles>"Restart Kernel" before Run the App .

@nhamde1998
Copy link

I was facing the same issue in Jupiter notebook. Go to kernel and restart and run all.

@bailong8281566
Copy link
Author

bailong8281566 commented Apr 25, 2020 via email

@no-response no-response bot removed the awaiting-reply Waiting for reply from issue opener, will be closed if no reply label Apr 25, 2020
@no-response no-response bot reopened this Apr 25, 2020
@rdoursenaud
Copy link

I think the issue is on line 87 of wm_pen.py written by @tito
The code assumes there is always an active window. Unfortunately it might be NULL/None.
I encountered it if window_state is set to hidden in kivy.Config for example and I quit the application using stop() from another thread.

@rdoursenaud
Copy link

wm_touch.py uses the same approach at line 111 and fails in the same way.
I’ve been able to workaround this by disabling both:

kivy.config.Config.remove_option('input', 'wm_pen')
kivy.config.Config.remove_option('input', 'wm_touch')

This is not ideal if you want to support windows pen and/or touch…

@matham
Copy link
Member

matham commented Mar 14, 2021

This is built into kivy that we only have one app at a time and that we have a window when running the app. So as suggested above for different IDE, you need to restart every time you run the app.

@matham matham closed this as completed Mar 14, 2021
@matham matham added the FAQ Issues that we need to document in a FAQ label Mar 14, 2021
@rdoursenaud
Copy link

My comment was from running kivy directly. Should I open another issue?

@matham
Copy link
Member

matham commented Mar 16, 2021

@rdoursenaud if you can reproduce the issue running kivy directly from a terminal and not from spyder/jupyter, then yeah you can open an issue with a reproducible example and full log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FAQ Issues that we need to document in a FAQ
Projects
None yet
Development

No branches or pull requests

7 participants