简体   繁体   中英

Cannot install Kivy (Ubuntu 20.04, python 3.8)

I have Python 3.8 installed on my Ubuntu 20.04 laptop. I want to run some code given to me that uses Kivy.

When I try to install Kivy using sudo pip3 install Kivy I get an error

Collecting Kivy
  Using cached Kivy-1.11.1.tar.gz (23.6 MB)
    ERROR: Command errored out with exit status 1:
[...]

I can install version 2.0.0rc3 with sudo pip3 install Kivy==2.0.0rc3 but my code won't work with this version

 Traceback (most recent call last):
   File "/usr/local/lib/python3.8/dist-packages/IPython/core/interactiveshell.py", line 3417, in run_code
     exec(code_obj, self.user_global_ns, self.user_ns)
   File "<ipython-input-2-8c0a5b6d250a>", line 1, in <module>
     runfile('myDir/myFile.py', wdir='myDir/')
   File "/snap/pycharm-professional/218/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
     pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
   File "/snap/pycharm-professional/218/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
     exec(compile(contents+"\n", file, 'exec'), glob, loc)
   File "myDir/myFile.py", line 142, in <module>
     FreePosApp().run()
   File "/home/thomas/.local/lib/python3.8/site-packages/kivy/app.py", line 949, in run
     self._run_prepare()
   File "/home/thomas/.local/lib/python3.8/site-packages/kivy/app.py", line 919, in _run_prepare
     root = self.build()
   File "myDir/myFile.py", line 127, in build
     textbox = Button(text = textBoxes[key][2],id=str(key), size_hint = textBoxes[key][1], pos = textBoxes[key][0],
   File "/home/thomas/.local/lib/python3.8/site-packages/kivy/uix/behaviors/button.py", line 121, in __init__
     super(ButtonBehavior, self).__init__(**kwargs)
   File "/home/thomas/.local/lib/python3.8/site-packages/kivy/uix/label.py", line 318, in __init__
     super(Label, self).__init__(**kwargs)
   File "/home/thomas/.local/lib/python3.8/site-packages/kivy/uix/widget.py", line 350, in __init__
     super(Widget, self).__init__(**kwargs)
   File "kivy/_event.pyx", line 245, in kivy._event.EventDispatcher.__init__
 TypeError: object.__init__() takes exactly one argument (the instance to initialize)
Process finished with exit code 137 (interrupted by signal 9: SIGKILL)

Thanks in advance

Try to update setuptools using the following command.

python -m pip install --upgrade --user pip setuptools

then try to install kivy.

Maybe I may be out of date, but python 3.8 is only compatible with this version of kivy(kivy 2.0.0).

The stable version of kivy is 1.11.1 which is compatible with python 2.7, 3.5, 3.6 and 3.7

You should try installing it in python 3.7.

If you need to use python 3.8, you should read the problem https://github.com/kivy/kivy/issues/6563 , and try the "matham" suggest.

pip install kivy[base] kivy_examples --pre --extra-index-url https://kivy.org/downloads/simple/

gook luck!

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