How does one access the Python library files that have been installed in /usr/local/lib/python3.10/dist-packages/PyQt6/bindings?
Some pages on the Internet say these libraries are installed in “site-packages”. That is not true for my install. It uses “dist-packages”.
I installed PyQt6 using “pip install PyQt6”.
When using this:
from PyQt6.QtWidgets import (QApplication, QWidget, QVBoxLayout, QPushButton,
QTextEdit, QTreeWidget, QTreeWidgetItem, QScrollArea)
from PyQt6.QtCore import Qt
I get “ModuleNotFoundError: No module named ‘PyQt6’”
You might also have to type it in as (all lower case):
pip install pyqt6
or
py -m pip install pyqt6
On a related note, a good IDE such as PyCharm has pip built-in so that you don’t have to manually type the importing of a module package. For example, with PyCharm, you just type the name of the library package in question, and the name will appear in the drop-menu. You click the Install Package button and it will install it for you.
It’s an option to consider.
If you need additional hep with this package, you can try going to this forum:
Paul is guessing that the version pip you ran does not match the version of python you run. I think you are on a debian or ubuntu system, is that right
In which case the command to run will be
python -m pip install PyQt6
But you may find that you can install pyqt6 that is package by debian/ubuntu and not need to use pip at all.
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If I try installing: apt install python3-pyqt6 or python3-qt6 it reports no such package exists.
python3 --version
Python 3.12.3
Despite 3.12.3 being installed “pip3” installs PyQt6 in /usr/local/lib/python3.10/dist-packages
I am sure pyqt6 is available to be installed. I will have to setup a vm and check what it is called. (I am a fedora user and only rarely use debian/ubuntu).
Debian was behind the change that forces you to use venv for ANY pip installed package. You could try creating a venv and install pyqt6 from pypi. But a ubuntu package pyqt6 would be best.
I am not familiar with Linux Mint, but the package does not appear to be available from their repos: Repository - Linux Mint
This is most likely because “pip3” on your system is actually /usr/local/bin/pip3, which in turn is actually /usr/local/lib/python3.10/dist-packages/pip. Exactly how this came to be is difficult to say. It depends entirely on how you installed python3.10 and python3.12, respectively.
If you want to be sure that you are using a specific version of python, and only installing and using packages for that version, the way to do that is to use a venv.
python3.12 -m venv myvenv creates a new venv called myvenv.
source myvenv/bin/activate activates the venv.
Once activated, you can install whatever packages you need using pip. Those packages will only be available with that venv.