Python Forum
PyQt5 Installation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyQt5 Installation
#1
I am trying to teach myself to code in Python using various resources and want to create my first, very simple, desktop application. I have no coding experience and do not know any other languages. I have, as far as I can tell, loaded PyQt5 onto my Windows computer. I have Python version 3.7.
I began by setting up a basic structure for the code. Guided by one of my learning resources I input:
[Python]
from PyQt5.QtCore import *
from PyQt5.QtGui import *
import sys



app = QApplication(sys.argv)
dialog = QDialog()
dialog.show()
app.exec_()
[\Python]

The result is:

C:\Users\BLACKBURNT\PycharmProjects\Pluralsight\venv\Scripts\python.exe C:/Users/BLACKBURNT/PycharmProjects/Pluralsight/structure.py
Traceback (most recent call last):
File "C:/Users/BLACKBURNT/PycharmProjects/Pluralsight/structure.py", line 1, in <module>
from PyQt5.QtCore import *
ModuleNotFoundError: No module named 'PyQt5'

Process finished with exit code 1

I do not know what I have done wrong when installing PyQt5. Can anyone help me please?
Reply
#2
How did you install PyQt5?
Reply
#3
(Feb-07-2020, 08:08 PM)Clamantium Wrote: venv\Scripts\python.exe
You are now running from virtual environment venv.
This mean that PyQt5 most be installed first in this environment.
Configure a Python interpreter here can you point Interpreter to OS version of Python,that i guess you have installed PyQt5 to.

Quick demo of venv.
# Make 
E:\div_code
λ python -m venv pyqt5_env

# Cd in
E:\div_code
λ cd pyqt5_env\

# Activate
E:\div_code\pyqt5_env
λ E:\div_code\pyqt5_env\Scripts\activate

# Install
(pyqt5_env) E:\div_code\pyqt5_env
λ pip install PyQt5
Collecting PyQt5
  Downloading ....
Successfully installed PyQt5-5.14.1 PyQt5-sip-12.7.1

# Test that it wok
(pyqt5_env) E:\div_code\pyqt5_env
λ python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt5.QtWidgets import QApplication, QWidget
>>>
>>> exit()
So if i was using PyCharm(which i am not) could point interpreter to E:\div_code\pyqt5_env\Scripts\python.exe
Then it will work PyCharm for this environment,and eg not for OS python if not also have installed PyQt5 there.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Huge code problems (buttons(PyQt5),PyQt5 Threads, Windows etc) ZenWoR 0 2,785 Apr-06-2019, 11:15 PM
Last Post: ZenWoR

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020