P
P
PendiPiper2019-12-09 23:51:58
Python
PendiPiper, 2019-12-09 23:51:58

How to import pyqt5 module?

Installed pyqt5 and pyqt5-tools via console. I can run the designer through the console.
But when I create a python file in python charm and try to import the PyQt5 module, it gives an error
No module named 'PyQt5'
there is a pyqt5 folder in lip\site-packages\
also after my unsuccessful attempts, many files in the pyqt folder open in pycharm in pyd format
Ready to provide screenshots if it helps
. Before that, I only worked with standard libraries (I apologize if the question sounds incorrect)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WStanley, 2019-12-10
@PendiPiper

1. Perhaps you installed it in a virtual environment, but did not activate it (virtual environment)
2. Check which interpreter is selected in pycharme python3, python2.7, or virtual environment is selected.
3. Check where you put pip freeze, pip3 freeze, or you need to activate the virtual environment and pip freeze there (depending on what and how and on which system you have installed)
Accordingly, you need to install the library for the selected interpreter, or select the interpreter which sees your
PendiPiper
library. In Linux, for example, python2.7 is already installed, respectively, its package manager is pip .

python -V  # проверить версию питона2
sudo apt install python-pip # установить пакетный менеджер
pip install name_package  # установка библиотеки для python2
pip freeze # просмотреть установленные библиотеки

If you additionally installed python3, then the package manager is pip3.
python3 -V # проверить версию питона3
sudo apt install python3-pip # установить пакетный менеджер
pip3 install name_package # установка библиотеки для python3
pip3 freeze # просмотреть установленные библиотеки

When setting up a virtual environment, you can specify which python will be used in the virtual environment, for example:
virtualenv -p python3 my_venv
virtualenv -p python my_venv

After installing the virtual environment, you need to activate it
source my_venv/bin/activate # в линуксе
source my_venv/Scripts/activate # в виндовсе

After activating the environment, you can check the version of python in the virtual environment
After that, you install the libraries you need in the virtual environment
pip install name_package # установить библиотеки
pip freeze # просмотреть установленные библиотеки
# только при активированном виртуальном окружении

and work with them only when the virtual environment is activated. The external python and python3 interpreters will not see them and vice versa.
Accordingly, in pyCharm (and other IDEs) you need to select the interpreter you are working with.
If you have Windows, the situation is similar, but there are nuances ..

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question