I'm running Windows 10, Python 3.8.5, kviy:
PS C:\Users\Zachs_Flex_5> pip -V
pip 20.2.3 from c:\users\zachs_flex_5\appdata\local\programs\python\python38-32\lib\site-packages\pip (python 3.8)
I don't understand what I did wrong
Code:
import kivy
from kivy.app import app
from kivy.uix.widget import widget
class MyGrid(Widget):
pass
class Main(Widget):
def build(self):
return Main()
if __name__ == "__main__":
Main().run()
name and main above have double underscore before and after
Error Message:
PS C:\Users\Zachs_Flex_5> &
C:/Users/Zachs_Flex_5/AppData/Local/Programs/Python/Python38-32/python.exe
c:/Users/Zachs_Flex_5/Documents/Main.py
/python.exe c:/Users/Zachs_Flex_5 Traceback (most recent call last):
File "c:/Users/Zachs_Flex_5/Documents/Main.py", line 1, in
import kivy ModuleNotFoundError: No module named 'kivy'
Related
I installed Panda3D with this command:
pip3 install panda3d==1.10.6
Then I made main.py:
from direct.showbase.ShowBase import ShowBase
from panda3d.core import WindowProporties
class Game(ShowBase):
def __init__(self):
ShowBase.__init__(self)
self.Proporties = WindowProporties
self.Proporties.setSize(500, 500)
self.win.requestProperties(properties)
if __name__ == "__main__": Game = Game()
When I run this code it give error:
python3 __main__.py
Error:
Traceback (most recent call last):
File "__main__.py", line 2, in <module>
from panda3d.core import WindowProporties
ImportError: cannot import name 'WindowProporties' from 'panda3d.core' (/home/kali/.local/lib/python3.8/site-packages/panda3d/core.cpython-38-x86_64-linux-gnu.so)
I am using:
Kali Linux Live
Python 3.8.2
Thanks to everyone in advance
Seems like you have a typo in your import, try this:
from panda3d.core import WindowProperties
import sys
if sys.version_info[0] < 3:
import Tkinter as tk ## Python 2.x
print("Python 2.X")
else:
import tkinter as tk ## Python 3.x
print("Python 3.X")
print("version", tk.TclVersion)
If I run from shell with python I get:
$ python test_tk
Python 2.X
('version', 8.6)
If I run from shell with python3 I get:
$ python3 test_tk
Python 3.X
version 8.6
But in PyCharm I get ImportError
Traceback (most recent call last):
File "/home/myuser/PycharmProjects/Project/file.py", line 12, in <module>
import tkinter as tk
File "/usr/lib/python3.5/tkinter/__init__.py", line 35, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named '_tkinter'
Process finished with exit code 1
I looked in PyCharm File>Default Settings>Project Interpreter>+ and it doesnt find any tkinter module...
I tried changing environment and in python 2.x I get:
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
From all the articles I read my conclusion would be that this is a path issue.
How can I resolve this?
I am trying to get my old project clipmanager building and I am encountering the following error:
/home/user/.virtualenvs/clipmanager27/bin/python /home/user/development/clipmanager/clipmanager/app.py
Traceback (most recent call last):
File "/home/user/development/clipmanager/clipmanager/app.py", line 15, in <module>
from mainwindow import MainWindow
File "/home/user/development/clipmanager/clipmanager/mainwindow.py", line 12, in <module>
import dialogs
File "/home/user/development/clipmanager/clipmanager/dialogs.py", line 8, in <module>
from PySide import QtWebKit
ImportError: cannot import name QtWebKit
Process finished with exit code 1
I installed Pyside with pip install pyside. I do not even see QtWebKit.so in the site packages folder /home/user/.virtualenvs/clipmanager27/lib/python2.7/site-packages/PySide:
Did it get removed due to licensing?
For Arch Linux, install qt4 and also qtwebkit before installing PySide.
After installing pyforms on my Raspberry Pi 3 i tried running the example i found on readthedocs, but the application is throwing an AttributeError (I tried both python2 and python3)
Python Code
import pyforms
from pyforms import BaseWidget
from pyforms.Controls import ControlText
from pyforms.Controls import ControlButton
class SimpleExample1(BaseWidget):
def __init__(self):
super(SimpleExample1,self).__init__('Simple example 1')
#Definition of the forms fields
self._firstname = ControlText('First name', 'Default value')
self._middlename = ControlText('Middle name')
self._lastname = ControlText('Lastname name')
self._fullname = ControlText('Full name')
self._button = ControlButton('Press this button')
#Execute the application
if __name__ == "__main__": pyforms.start_app( SimpleExample1 )
Error:
Traceback (most recent call last):
File "PiControl.py", line 20, in <module>
if __name__ == "__main__": pyforms.start_app( SimpleExample1 )
AttributeError: ‘module’ object has no attribute ‘start_app’
Edit:
I tried to import start_app manually with
from pyforms.gui.standaloneManager import start_app
but then I get another ImportError:
Traceback (most recent call last):
File "PiControl.py", line 4, in <module>
from pyforms.gui.standaloneManager import start_app
ImportError: cannot import name 'start_app'
This is very strange behavior and possibly means that your installation is broken. Try to install the latest versions from a repo:
pip install -U git+https://github.com/UmSenhorQualquer/pyforms.git
pip install -U git+https://github.com/UmSenhorQualquer/pysettings.git
pip install -U git+https://bitbucket.org/fchampalimaud/logging-bootstrap.git
I installed the Kivy lib, and have been trying to get it to work all day.
I tried following the simple tutorial:
import kivy
kivy.require('1.9.0')
from kivy.app import App
from kivy.uix.label import Label
class MyApp(App):
def build(self):
return Label(text='Hello world')
if __name__ == '__main__':
MyApp().run()
When trying to run from file i get the following error:
Traceback (most recent call last):
File "random.py", line 1, in <module>
import kivy
File "C:\Python34\lib\site-packages\kivy\__init__.py", line 38, in <module>
from kivy.logger import Logger, LOG_LEVELS
File "C:\Python34\lib\site-packages\kivy\logger.py", line 61, in <module>
from random import randint
File "random.py", line 2, in <module>
from kivy.app import App
File "C:\Python34\lib\site-packages\kivy\app.py", line 315, in <module>
from kivy.config import ConfigParser
File "C:\Python34\lib\site-packages\kivy\config.py", line 272, in <module>
from kivy import kivy_config_fn
ImportError: cannot import name 'kivy_config_fn'
Press any key to continue . . .
Confusingly enough, it works in the interactive just fine... (able to build class and run app with exact same code)
Notes:
Already tried reinstalling
Installed Kivy from here
Specs:
Window 8.1
Python 3.4
Thanks in advance
Okay so after some googling, i finally found my answer.
I followed this guide and got everything to work:
How to use PTVS to develop and run Kivy applications
And also this from 2013 stating that you can't use Kivy as a regular module.
How to use PyDev to develop and run Kivy applications