Как установить библиотеку pyqt5 в pycharm
Перейти к содержимому

Как установить библиотеку pyqt5 в pycharm

  • автор:

How to install PyQt5 in PyCharm

PyQt5 is a toolkit for creating Python GUI applications. As a cross-platform toolkit, PyQt can run on all major operating systems (Unix, Windows (Mac).

This article describes how to install Python + PyCharm + PyQt5.

With PyQt5, the GUI is designed in two ways:

  • directly using the code to design the interface
  • using QtDesigner to visualize the design, and then convert the resulting .ui file into a .py file.

Install Python + PyCharm + PyQt5.

Step 1. Install Python.

Visit the official website at https://www.python.org/ to download and install your target Python version.

Install PyQt5

Enter the cmd interface. Run the command and wait a moment.

pip install pyqt5 pyqt5-tools 

The command is executed and PyQt5 is installed.

Test if pqyt5 is actually installed

Create a new file, example.py, and enter the following code.

import sys from PyQt5 import QtWidgets, QtCore app = QtWidgets.QApplication(sys.argv) widget = QtWidgets.QWidget() widget.resize(400, 200) widget.setWindowTitle("This is PyQt Widget example") widget.show() exit(app.exec_()) 

After running, the following screen will pop up, indicating that PyQt is working normally.

pyqt widget

3. Install PyCharm.

Visit the official website http://www.jetbrains.com/pycharm/
Choose download and install Community version.

PyCharm Basic Configuration.

Step 1 Create a new project

Step 2 Set the default PyCharm parser.

Select File | Settings | Project: first | Project Interpreter, set Project Interpreter to The version of python you are using

pycharm python version

Step 3 Adding third-party libraries

Stay in the Project Interpreter interface, click on the +, find and install pyqt5. pyqt5-sip, pyqt5-tools. After successful installation, the interface should look like this.

pycharm install pyqt

Step 4 Configuring QtDesigner

Install designer
You can start designer directly from PyCharm. Make sure designer is installed first. Designer is not installed with the pip installation.

On Fedora Linux you can do this:

sudo dnf install qt5-designer 

Ubuntu Linux users can do thiS:

sudo apt-get install qttools5-dev-tools 

You can also do this:

pip install pyqt5-tools 

Once qt5-designer is installed, you can configure it in PyCharm.

PyCharm select File | Settings | Tools | PyCharm. External Tools, click + New Tools, Create QTdesigner and PyUIC tools

pycharm configure qtdesigner

Configure two key parameters.

    Program: the path to your own designer .

    Windows users can link to designer.exe , for example C:\\xxxx\AppData\Local\Programs\Python\Python35-32\\Lib\site-packages\pyqt5-tools\designer.exe

Step 5: Configure PyUIC

pyuic in pycharm

Configure three key parameters.

  • Program: Your own python.exe path For example, C:\\xxxx\AppData\\Local\Programs\Python\Python35-32\python .
  • Arguments: -m PyQt5.uic.pyuic $FileName$ -o $FileNameWithoutExtension$.py
  • Working directory: $ProjectFileDir$

Test PyQt installation

From code

Now that everything is setup, it’s time to test if everything is setup correctly.
Create a GUI interface using the code below (or any PyQt code).

from PyQt5 import QtWidgets # import PyQt5 widgets import sys # Create the application object app = QtWidgets.QApplication(sys.argv) # Create the form object first_window = QtWidgets.QWidget() # Set window size first_window.resize(400, 300) # Set the form title first_window.setWindowTitle("The first pyqt program") # Show form first_window.show() # Run the program sys.exit(app.exec()) 

Select Run->Run first. You should see a PyQt window popup.

QTDesigner

Use QTDesigner to generate a GUI interface and convert it to a .py file using PyUIC.

pycharm start qtdesigner

In the QT Designer interface, a GUI creation interface will pop up for the first time, click on create to automatically generate a GUI interface.

qtdesigner

Save the interface as Untitled.ui file.

pyqt ui file

Back to the PyCharm project interface, there is an extra .ui file under the project list.

Right-click on Untitled.ui and select ExternalTools->PyUIC in the pop-up list.

pyqt generate ui

This will generate a Untitled.py file for Untitled.ui.

Copyright (c) 2020 pythonpyqt.com

Copyright (c) 2020-2023

Установка PyQt5 через PyCharm

Author24 — интернет-сервис помощи студентам

Ошибка PyCharm (PyQt5)
При попытке запустить тестовую программу import sys from PyQt5 import uic from PyQt5.QtWidgets.

Импорт в PyCharm PyQt5
Появилась проблема после обновления PyQt5 до версии 5.7.1. С импортом такая фигня: Возврат на.

Re: PyCharm+PyQt5 .exe installer
установил Pyinstaller написал простую формочку. скомпелил. получил .exe. запускаю но вместе с.

PyCharm+PyQt5 .exe installer
запускаю в пайчарм код с использованием PyQt5.(python 3) подучаю формачки. вопроса два: как.

Эксперт Python

4632 / 2050 / 361
Регистрация: 17.03.2012
Сообщений: 10,134
Записей в блоге: 6
Интернета нет. Connection time out.
Интересно, есть ли тут какая-нибудь связь?
242 / 35 / 8
Регистрация: 05.05.2012
Сообщений: 521

Ну а можно как-то без интернета установить этот пакет в PyCharm​​? Он скачан. Интернета тут не будет. Это рабочий комп.

Эксперт Python

4632 / 2050 / 361
Регистрация: 17.03.2012
Сообщений: 10,134
Записей в блоге: 6

Simply me, можно, натравить на него pip, он умеет устанавливать из whl.

Ещё у PyQt, кажется, есть собственный установщик в виде exe, но с его помощью, по-моему, ещё никому и никогда не удавалось установить PyQt, чтобы он заработал, так что лучше и не пытаться.

242 / 35 / 8
Регистрация: 05.05.2012
Сообщений: 521
А как правильно с помощью pip? Не получается.

Эксперт Python

4632 / 2050 / 361
Регистрация: 17.03.2012
Сообщений: 10,134
Записей в блоге: 6

Ну во-первых, у вас система не находит pip. Во-вторых, так устанавливают из инета. Если из локального whl — подайте ему путь к whl. В faq пример показан.

Регистрация: 01.04.2017
Сообщений: 118

К рабочему компу можно подключить любой смартфон, который даст ему доступ к сети. Более жестким вариантом будет перемещение харда, или пк поближе к интернету. Также как указал уважаемый dondublon возможна установка whl файла, если конечно ваш файл с данным расширением(что вы не указали). Также установка Анаконды добавит вам кути, а заодно еще и кучу модулей.

Добавлено через 13 минут
Посмотрите в сторону «визуал бейсик НЕТ». Интерфейсы пишутся на порядок легче.

Эксперт Python

4632 / 2050 / 361
Регистрация: 17.03.2012
Сообщений: 10,134
Записей в блоге: 6
pazurs, не стоит делать девушке такие непристойные предложения.
636 / 476 / 179
Регистрация: 28.05.2012
Сообщений: 1,414

ЦитатаСообщение от pazurs Посмотреть сообщение

Посмотрите в сторону «визуал бейсик НЕТ». Интерфейсы пишутся на порядок легче.
Ну тогда уж лучше в сторону c# WPF
242 / 35 / 8
Регистрация: 05.05.2012
Сообщений: 521

А расскажите, пожалуйста, подробнее, как с помощью whl. Хотя у меня файл с кодом с расширением py.

Телефон как модем я раньше подключала. Удобно было, хоть и вылетало из корпоративной почты и коммуникатора. А сейчас безопасники как-то это пресекли. Даже когда телефон подключен как модем, нет интернета.

Эксперт Python

4632 / 2050 / 361
Регистрация: 17.03.2012
Сообщений: 10,134
Записей в блоге: 6
FAQ прочитали?
Проще некуда. pip install mypackage.whl.
242 / 35 / 8
Регистрация: 05.05.2012
Сообщений: 521
У меня же ругается на команду pip. Каталог, может, поменять надо.
Регистрация: 27.05.2019
Сообщений: 115

Simply me, если у тебя не установлен pip на пк, то установи сначала pip, вписав curl*пробел*https://bootstrap.pypa.io/get-pip.py -o get-pip.py, а потом python get-pip.py
Вот информация о pip, если надо — https://pip.pypa.io/en/stable/installing/

Добавлено через 2 минуты
А потом уже попробуй установить пакет

Эксперт Python

4632 / 2050 / 361
Регистрация: 17.03.2012
Сообщений: 10,134
Записей в блоге: 6

ЦитатаСообщение от Simply me Посмотреть сообщение

У меня же ругается на команду pip. Каталог, может, поменять надо.

Я думал, с этим уже разобрались.
Посмотрите, что такое PATH в system environment (переменные окружения). Можно обойтись и без него, но для понимания.

Vladks, не путайте человека. pip идёт в комплекте с питоном.

Регистрация: 27.05.2019
Сообщений: 115

dondublon, ну не знаю, до того как я установил pip(который привёл по ссылке) у меня многие модули либо не устанавливались, либо ставились с некоторыми косяками, после установки pip’а всё работает нормально, Python ни на что не ругается

Добавлено через 12 секунд
Ну да лан

Эксперт Python

5418 / 3842 / 1214
Регистрация: 28.10.2013
Сообщений: 9,554
Записей в блоге: 1

ЦитатаСообщение от Vladks Посмотреть сообщение

у меня многие модули либо не устанавливались, либо ставились с некоторыми косяками

Раз хоть как-то устанавливались — значит pip же был. Иначе вообще бы вы ничего не смогли установить из репозитория pypi.
pip нужно не устанавливать, а обновлять. О необходимости обновления он сам всегда пишет желтыми (ранее красными) строками.
Какой именно командой обновлять — он сам всегда пишет желтыми (ранее красными) строками.

You are using pip version 18.1, however version 19.1.1 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command

Добавлено через 1 минуту

ЦитатаСообщение от Simply me Посмотреть сообщение

Каталог, может, поменять надо.
Можно и поменять.

cd /d "путь_к_Python\scripts"
1 2 3 4 5 6 7 8
Вот сколько их тут: c:\>cd /d D:\INSTALL\Python3\scripts D:\INSTALL\Python3\Scripts>dir |findstr "pip" 20.02.2018 21:14 89*444 pip-review.exe 23.03.2019 23:51 93*022 pip.exe 23.03.2019 23:51 93*022 pip3.5.exe 10.01.2017 19:02 89*428 pip3.5.exe.deleteme 23.03.2019 23:51 93*022 pip3.exe

но лучше добавить это путь в PATH, как вам и посоветовали.
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
Помогаю со студенческими работами здесь

PyCharm не видит метод addWidget() модуля PyQt5
Приветствую. Установил модуль PyQt5 на Python 3.6. Начал создавать первое оконное приложение и.

Установка PyCharm
Добрый день, друзья! Подскажите, пожалуйста. Пэйчарм перестал видеть интерпретатор, хотя до этого.

Установка PyQt5
Всем привет. У меня стоит Ubuntu 14.04, решил установить PyQt5. Скачал исходники с официального.

Установка pip в PyCharm
Столкнулся с такой проблемой, что когда хочу установить PyAudio через терминал PyCharm, командой.

Установка mysql в pycharm
Подскажите как добавить модуль mysql в pycharm pip install mysql выдает ошибки _mysql.c .

Установка Django на Pycharm
Помогите! Устанавливаю Django для pycharm(2018.3.3 x64), питон — последняя версия(3.7.2), .

Или воспользуйтесь поиском по форуму:

How to Install PyQt5 on PyCharm?

PyQt5 is a Python library for Qt version 5. Qt is a collection of C++ libraries for accessing modern desktop and mobile systems such as location and positioning services, multimedia, NFC and Bluetooth connectivity, web browser, and UI.

Problem Formulation: Given a PyCharm project. How to install the PyQt5 library in your project within a virtual environment or globally?

Here’s a solution that always works:

  • Open File > Settings > Project from the PyCharm menu.
  • Select your current project.
  • Click the Python Interpreter tab within your project tab.
  • Click the small + symbol to add a new library to the project.
  • Now type in the library to be installed, in your example «PyQt5» without quotes, and click Install Package .
  • Wait for the installation to terminate and close all popup windows.

Here’s the installation process as a short animated video—it works analogously for PyQt5, just type in “pyqt5” in the search field instead:

Make sure to select only “PyQt5” because there are many other packages that are not required but also contain the term “pyqt5” (False positives):

pyqt5 install package PyCharm settings

Alternatively, you can run the pip install PyQt5 command in your PyCharm “Terminal” view:

$ pip install PyQt5

pip install pyqt5 PyCharm

Feel free to check out the following free email academy with Python cheat sheets to boost your coding skills!

To become a PyCharm master, check out our full course on the Finxter Computer Science Academy available for free for all Finxter Premium Members:

While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students.

To help students reach higher levels of Python success, he founded the programming education website Finxter.com that has taught exponential skills to millions of coders worldwide. He’s the author of the best-selling programming books Python One-Liners (NoStarch 2020), The Art of Clean Code (NoStarch 2022), and The Book of Dash (NoStarch 2022). Chris also coauthored the Coffee Break Python series of self-published books. He’s a computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.

His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.

Categories Dependency Management, PyCharm, Python

Be on the Right Side of Change ��

  • The world is changing exponentially. Disruptive technologies such as AI, crypto, and automation eliminate entire industries. ��
  • Do you feel uncertain and afraid of being replaced by machines, leaving you without money, purpose, or value? Fear not! There a way to not merely survive but thrive in this new world!
  • Finxter is here to help you stay ahead of the curve, so you can keep winning as paradigms shift.

Learning Resources ��‍��

⭐ Boost your skills. Join our free email academy with daily emails teaching exponential with 1000+ tutorials on AI, data science, Python, freelancing, and Blockchain development!

Join the Finxter Academy and unlock access to premium courses �� to certify your skills in exponential technologies and programming.

New Finxter Tutorials:

  • [Fixed] Error Code 429: Quota Exceeded
  • What is Hugging Face Used For? Exploring its Applications in Machine Learning
  • Bitcoin Trading Simulation (Free Online Game)
  • Creating a Live Bitcoin Price Chart Using Binance API (No API Key!)
  • Google Making Billions of AI – The Investment Case for Alphabet
  • Tesla Leaps in Artificial Intelligence – Robotaxi, Optimus Bot, and FSD Updates Q1 2024
  • Python Object Creation: __new__ vs __init__
  • Python Check If an Integer is in Range
  • 5 Best Ways to Edit Large Text Files in Windows
  • Python Create List From 1 to N with Step Size

Finxter Categories:

Import problems python/pyqt

Ive got some import problems in python. When I want to import the PyQt5 library I just get the error «No module named ‘PyQt5′». The folder is in the path C:\Python\Python37\Lib\PyQt5. I can import tkinter and the folder is in the same path as PyQt5 Code: from PyQt5 import QtCore, QtGui, QtWidgets Error:ModuleNotFoundError: No module named ‘PyQt5’

asked Nov 10, 2020 at 6:47
13 5 5 bronze badges
Welcome to SO. Please post your error as text and not image.
Nov 10, 2020 at 6:52
How did you install the modules? Are you using a virtual environment?
Nov 10, 2020 at 6:57
Im using the environment from pycharm which was created at the start.
Nov 10, 2020 at 6:58

I converted a UI file from the QT Designer to a .py which is in the path C:\Python\Python37\Lib\PyQt5

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *