I wrote a program in Python 3.4 and I want to make a GUI for it. I"ve found that PyQt5 - is the tool for it.
1) I've downloaded and installed a binary package of PyQt5 (http://ift.tt/1aK63Sr).
2) I tried to run this example code in Python:
import sys
from PyQt5.QtWidgets import QApplication, QWidget
if __name__ == '__main__':
app = QApplication(sys.argv)
w = QWidget()
w.resize(250, 150)
w.move(300, 300)
w.setWindowTitle('Simple')
w.show()
sys.exit(app.exec_())
Python returned en error:
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\PyQt5.py", line 2, in <module>
from PyQt5.QtWidgets import QApplication, QWidget
File "D:\PyQt5.py", line 2, in <module>
from PyQt5.QtWidgets import QApplication, QWidget
ImportError: No module named 'PyQt5.QtWidgets'; 'PyQt5' is not a package
3) I found an advise to install QT. So, I downloaded and installed QT (http://ift.tt/1E0Ocm1).
4) Then I've uninstalled and installed again a binary package of PyQt5. No results.
Python doesn't return any errors if I run:
import PyQt5
But if I try to run:
from PyQt5.QtWidgets import QApplication, QWidget
It returns the same error as in the beginning.
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\PyQt5.py", line 2, in <module>
from PyQt5.QtWidgets import QApplication, QWidget
File "D:\PyQt5.py", line 2, in <module>
from PyQt5.QtWidgets import QApplication, QWidget
ImportError: No module named 'PyQt5.QtWidgets'; 'PyQt5' is not a package
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire