What is wrong with qt5 libs? - python-3.x

I tried to code simple exercise on qt5:
main.py:
import sys
from PySide2.QtWidgets import QApplication, QLabel
app = QApplication(sys.argv)
label = QLabel("Hello World!")
label.show()
app.exec_()
When I tried to start I got errors which are linked with Qt5 libs:
(base) [redf1sh#redPC ~]$ export QT_DEBUG_PLUGINS=1
(base) [redf1sh#redPC ~]$ python3 main.py
...
Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/home/redf1sh/anaconda3/bin/platforms" ...
Cannot load library /home/redf1sh/anaconda3/plugins/platforms/libqxcb.so: (/home/redf1sh/anaconda3/plugins/platforms/../../lib/libQt5XcbQpa.so.5: undefined symbol: _ZN11QFontEngine14bitmapForGlyphEj6QFixedRK10QTransform, version Qt_5_PRIVATE_API)
QLibraryPrivate::loadPlugin failed on "/home/redf1sh/anaconda3/plugins/platforms/libqxcb.so" : "Cannot load library /home/redf1sh/anaconda3/plugins/platforms/libqxcb.so: (/home/redf1sh/anaconda3/plugins/platforms/../../lib/libQt5XcbQpa.so.5: undefined symbol: _ZN11QFontEngine14bitmapForGlyphEj6QFixedRK10QTransform, version Qt_5_PRIVATE_API)"
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, minimal, minimalegl, offscreen, vnc, xcb.
I've installed pyqt5 packages, pyside2 with pip.
Can you help me with this?

I solved it by myself.
Firstly, I found all packages in the system that are connected to qt and removed them:
$ pip list | grep qt
$ pip uninstall *smth*
$ conda list | grep qt
$ conda remove *smth*
$ pacman -Qe | grep qt
# pacman -R *smth*
and secondly is clear install only from pacman (not plugins in pip or conda)
# pacman -S qt5 pyside2 python-pyqt5
and now all is working well

Related

PyInstaller weird PyQt5.sip import causes a failed EXE [duplicate]

After upgrading to python-pyqt5 5.12-2 I get this error when I try to import from QtWidgets
from PyQt5.QtWidgets import *
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.sip'
Any idea on how can I solve this issue?
The reason is a backward incompatible change in PyQt-5.11
In geoptics this fix works on old and new versions:
try:
# new location for sip
# https://www.riverbankcomputing.com/static/Docs/PyQt5/incompatibilities.html#pyqt-v5-11
from PyQt5 import sip
except ImportError:
import sip
As suggested here pyuic5 - ModuleNotFoundError: No module named PyQt5.sip
Try uninstalling and re-installing all PyQt related libraries:
pip uninstall PyQt5
pip uninstall PyQt5-sip
pip uninstall PyQtWebEngine
Then install them again, this will fix:
ModuleNotFoundError: No module named 'PyQt5.sip'
ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'
PPS.:If you got problems uninstalling the libraries, go to your Python folder, like C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python<PYTHON-VERSION>\Lib\site-packages and manually delete the PyQt folders, them uninstall everything and install again (Make sure you have the latest Python version and upgraded your pip too)
If you're building sip and PyQt5 from source using make files, make sure to check PyQt5 install docs. In particular,
Note
When building PyQt5 v5.11 or later you must configure SIP to create a
private copy of the sip module using a command line similar to the
following:
python configure.py --sip-module PyQt5.sip
If you already have SIP installed and you just want to build and
install the private copy of the module then add the --no-tools option.
You should add PyQt5.sip to hidden imports; that should solve the issue.
I repaired this problem
This problem occurred when upgrading pyqt5 version 5.15.0
There was no problem when I reverted to the previous version.
I have
python -V: 3.7.4
PYQT5 5.14.1 and PYSIDE 5.14.1 works fine
In addition to the answer provided by Tadeu (https://stackoverflow.com/a/58880976/12455023) I would also suggest checking version of your libraries to make sure that they match.
Use pip show <library_name>
This will help you to make sure that no earlier installation is conflicting with your current installation.
In place of library_name use PyQt5, PyQt5-sip, PyQtWebEngine. If any of them is present in the system, then use pip uninstall <library_name>==<version_number> to remove that library.
Once you made sure that no other versions of these libraries are there, then you can reinstall the preferred version of that library.

Using Homebrew python3 with both homebrew packages and pip/pip3 packages in Visual Studio Code for Mac OS

I am currently trying to setup Visual Studio Code on Mac OSX 10.13.6 for coding in python3. I'd like to avoid using multiple virtual environments for my different python3 scripts and instead have them all run using:
(1) the same homebrew installation of python3
(2) accessing installed python packages in:
homebrew packages list
pip3 installed package list
pip installed packages list.
First, I first installed python3 using homebrew:
$ brew info python
python: stable 3.7.7 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python/3.7.7 (4,062 files, 62.4MB)
...
Python has been installed as
/usr/local/bin/python3
...
You can install Python packages with
pip3 install <package>
They will install into the site-package directory
/usr/local/lib/python3.7/site-packages
Second, I installed my required packages using homebrew:
$ brew list
cmake libffi p11-kit
dcraw libheif pandoc
dlib libidn2 pcre
...
jasper numpy webp
...
And other packages using pip and pip3:
$ pip list
DEPRECATION:...
Package Version
-------------------------------------- --------
altgraph 0.10.2
...
numpy 1.8.0rc1
...
zope.interface 4.1.1
$
$ pip3 list
Package Version
------------------ -------
appnope 0.1.0
...
numpy 1.18.2
pandocfilters 1.4.2
parso 0.5.2
pexpect 4.7.0
pickleshare 0.7.5
pip 20.0.2
pomegranate 0.12.2
...
scipy 1.4.1
Third, I opened Visual Studio Code and in "Preferences" -> "Settings" and set "Python:Python Path" to the homebrew python3 installation as noted above /usr/local/bin/python3.
See this screenshot:
Next, I added /usr/local/lib/python3.7/site-packages per the homebrew install of python3 to the Visual Studio Code Settings file using:
"python.autoComplete.extraPaths": [
"/usr/local/lib/python3.7/site-packages" ]
Finally, I selected my python interpreter in Visual Studio Code as /usr/local/bin/python3 and tried to run the following 2-lines of imports in a .py script as per the screenshot below. Note that the interpreter is Python 3.7.0 64-bit given by the bottom left corner of the VS Code window.
And after all of that, ended up with this output after clicking the "Play" button to run the code in the top right corner of VS Code:
[Running] python -u "/Users/...bayes_net_nodes.py"
Traceback (most recent call last):
File "/Users/...bayes_net_nodes.py", line 1, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
[Done] exited with code=1 in 0.037 seconds
What would be the most simple way to configure VS Code so I can run python3 scripts that have access to the all the packages I've installed across my system without using virtual environments? Thank you!
Note: One workaround that seems to work, and I'm not sure why is if I put a shebang at the top of my script #! /usr/local/bin/python3 and my output then looks like this:
[Running] /usr/local/bin/python3 "/Users/...bayes_net_nodes.py"
[Done] exited with code=0 in 0.051 seconds
Which is odd, because that's different than the output above where I didn't use the shebang but both python interpreters according to VSCode are indeed /usr/local/bin/python3
I was able to reproduce your problem.. but only when I use Code Runner to run.
Those kind of Output logs with [Running] and [Done] is Code Runner.
The play button is also not green, indicating Code Runner because the default is green.
Now, for the fix!
You'll notice that it executed your script using python -u. That python would be whatever python means on your system, which for me is the default Python 2.7. Basically, it's not your Homebrew Python3 with numpy.
Code Runner has a default set of "executors" which tells it which executable to use for which language. Search it for in your settings as "code-runner Executor Map":
Open your settings.json, enter code-runner.executorMap, then let it auto-complete with the default. You'll then see a long list of mappings between language and executor. Look for the one for python:
"code-runner.executorMap": {
"javascript": "node",
...
"python": "python -u",
"perl": "perl",
...
}
And there it is: python -u, the same one it used to run your script.
If you want to continue using Code Runner, simply change it to the whichever python interpreter you want to use. In your case, it should be /usr/local/bin/python3:
"code-runner.executorMap": {
...
"python": "/usr/local/bin/python3",
...
}
It should now work:
The reason it works with a #! /usr/local/bin/python3 shebang is because Code Runner has a setting that it respects the file's shebang (code-runner.respectShebang) which is true by default.
If you don't want this extra step of setting-up Code Runner, you can simply disable (or uninstall it). All the steps you already did (setting python.pythonPath, selecting the interpreter, and clicking that Play button) would have already worked just fine with Microsoft's Python extension. See the official docs on running Python files, selecting environments, and debugging.

How do I install curses library in my editor?

I cannot install the curses library in my Editor. Is there some other way to make sure I have the library installed and can import it?
I'm trying to build a tictactoe game using venv, in Pycharm Community Edition. I imported curses in the directory where my scripts are located using command prompt. I can import curses in IDLE editor. However, there is no package called curses in the Settings->Project Interpreter.
pip install curses‑2.2‑cp36‑cp36m‑win_amd64.whl
this throws an error:
Requirement 'curses-2.2-cp36-cp36m-win_amd64.whl' looks like a
filename, but the file does not exist
curses-2.2-cp36-cp36m-win_amd64.whl is not a supported wheel on this
platform.
Edited the configurations and checked the checkbox with emulate terminal in output console, still won't work.
You should use:
pip install https://download.lfd.uci.edu/pythonlibs/n5jyqt7p/curses-2.2.1+utf8-cp37-cp37m-win_amd64.whl
The section of the pip command line installer:
cp37 == CPython 3.7
So you need the appropriate whl install file for your installed Python environment.

PyGObject for Python 3.5.1?

I am using Debian Linux, and I have the package python3-gi installed from Synaptic, and this works fine if I use my Python 3.4 interpreter. But, when I run a Gtk+3 program using 3.5, it gets stuck at the from gi.repository import Gtk line, saying there's no module named Gtk. Additionally, I don't think that pip works for Python 3.5 on my computer, although I'm not sure. I just know that pip install PyGObject doesn't work. Finally, when I try to use Pycharm's specific package installer (Settings/Project Interpreter), Pycharm tells me that I don't have Python packaging tools installed (and it fails to install them when I click on the prompt it gives).
I have a 64 bit computer, Python 3.5 is installed to /usr/local/bin/ and Python 3.4 is installed to /usr/bin/.
You cannot use pip, you would have to download pygobject and build it from source yourself. https://download.gnome.org/sources/pygobject/
This is how I got Python 3.6 up and running with GStreamer bindings etc. on my Mac OS Sierra.
Follow from Step 1 if you have already installed Gstreamer and its plugins and you need to bind it to your python interpreter for development.
0a- Install gstreamer from their website ...normally and then
0b- brew install gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav
1- brew install gst-python --with-python3
Note however that the 'gtk' for some reason doesn't come pre-bundled so we go to step 2.
2- brew install gtk+3
And that's it, easy as ABC...
Attached is a test python code to make sure you got everything right [OPTIONAL]
import gi, time, sys
gi.require_version('Gst', '1.0')
gi.require_version('GstBase', '1.0')
gi.require_version('Gtk', '3.0')
from gi.repository import GObject, Gst, GstBase, Gtk, GObject
class Main:
def __init__(self):
Gst.init(None)
self.pipeline = Gst.Pipeline()
self.audiotestsrc = Gst.ElementFactory.make('audiotestsrc', 'audio')
self.pipeline.add(self.audiotestsrc)
self.sink = Gst.ElementFactory.make('autoaudiosink', 'sink')
self.pipeline.add(self.sink)
self.audiotestsrc.link(self.sink)
self.pipeline.set_state(Gst.State.PLAYING)
time.sleep(3)
self.pipeline.set_state(Gst.State.PAUSED)
self.pipeline.set_state(Gst.State.READY)
self.pipeline.set_state(Gst.State.NULL)
sys.exit(0)
start = Main()
Gtk.main()
Hope er'thing works out, c ya!!

Making pip working under python 3.4

I used easy install with Python 2.7 and now try to update to Python 3.4 but the pip is not very clear.
My OS is Windows 7 - 64Bits and I do not have administrator rights. For the moment I enter in a terminal:
C:\Users\bc50414\Documents>pip install Pyside
Fatal error in launcher: Unable to create process using '""C:\Program Files (x86)\Python34\python.exe"" "C:\PF86\Python34\Scripts\pip.exe" install Pyside'
Where pip is just an alias for doskey pip=C:\PF86\Python34\Scripts\pip.exe $*. Apparently there is a problem with spaces, so using this solution (python3=C:\PF86\Python34\python.exe $*):
C:\Users\bc50414\Documents>python3 -m pip install Pyside
Downloading/unpacking Pyside
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement Pyside
Cleaning up...
No distributions at all found for Pyside
Storing debug log for failure in C:\Users\bc50414\pip\pip.log
Still fails ... the log is:
C:\PF86\Python34\lib\site-packages\pip\__main__.py run on 02/02/15 09:14:35
Downloading/unpacking Pyside
Getting page https://pypi.python.org/simple/Pyside/
Could not fetch URL https://pypi.python.org/simple/Pyside/: timed out
Will skip URL https://pypi.python.org/simple/Pyside/ when looking for download links for Pyside
Getting page https://pypi.python.org/simple/
I guess it is a problem of Firewall/proxy since I am in a firm using this...so I tried this:
C:\Users\bc50414\Documents>python3 -m pip install --proxy="XXXXXmyproxyXXXXX" Pyside
Downloading/unpacking Pyside
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement Pyside
Cleaning up...
No distributions at all found for Pyside
Storing debug log for failure in C:\Users\bc50414\pip\pip.log
I really do not know hopw to solve this problem and afraid I am stuck with a lot of code in Python and pacakge I can't reach ...
PIP should already be included with Python 3.x
Open a command prompt in windows.
and type pip
you can open a command prompt by pressing windows button then type cmd in search for programs.
It should also be installed in accessories folder from your windows start button.

Resources