I've faced an issue while using Python3 / PyQt5 on a brand new Qt5 installation
My environment is:
LSB Version: core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch
Distributor ID: Ubuntu
Description: Ubuntu 12.04.4 LTS
Release: 12.04
Codename: precise
I've installed QT5 and PyQt5 without any problem. When creating the py module from QT UML description, the process fails with a SIP version error.
command:
pyuic5 uml/console.ui -o console_ui.py
results as:
File "/usr/lib/python3.2/site-packages/PyQt5/uic/pyuic.py", line 26, in <module>
from PyQt5 import QtCore
RuntimeError: the sip module implements API v8.0 to v8.1 but the PyQt5.QtCore module requires API v10.1
pyuic5 ui_path/myfile.ui -o ui_path/myfile_ui.py
my SIP version is :
jeby6372#junon:~$ sip -V
4.15.4
SIP 4.15.4 is the lastest version delivered by RiverBank.
I've removed the old QT4 environment so I think there's somewhere a bad link to the corresponding old SIP version.
Numerous similar issues have been posted on the web but none got an valuable answer.(when they're even answered).
Thanks for yor help.
Emmanuel.
Just need to remove python-sip and install again sip-4.15.4. The packaged python3-sip is out of date for PyQt5
Related
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.
I'm trying to import opencv2 using python3.7.3 on Mac OS 10.10 but an ImportError occurs. How should I solve it?
I tried to install opencv3 using pip, pip3, and homebrew. Probably not install right.
import cv2
import numpy as np
import sys
import pytesseract as py
import matplotlib.pyplot as plt
Error
Traceback (most recent call last):
File "/Users/wujian/Desktop/Project/Proj.py", line 1, in <module>
import cv2
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cv2/__init__.py", line 3, in <module>
from .cv2 import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cv2/cv2.cpython-37m-darwin.so, 2): Symbol not found: _clock_gettime
Referenced from: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cv2/.dylibs/libavutil.56.22.100.dylib (which was built for Mac OS X 10.12)
Expected in: /usr/lib/libSystem.B.dylib
in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cv2/.dylibs/libavutil.56.22.100.dylib
The issue seems to be (oddly) related to your copy of libavutil which is part of ffmpeg.
It's hinted at by this part of the error message:
ImportError: dlopen(/.../cv2/cv2.cpython-37m-darwin.so, 2): Symbol not found: _clock_gettime
Referenced from: /...python3.7/site-packages/cv2/.dylibs/libavutil.56.22.100.dylib (which was built for Mac OS X 10.12)
Installing OpenCV requires ffmpeg. If you installed it via homebrew, it's listed as a dependency.
$ brew info opencv
...
==> Dependencies
Build: cmake ✓, pkg-config ✓
Required: eigen ✓, ffmpeg ✓, glog ✓, ...
Installing ffmpeg will include the libavutil library, which can be checked by downloading pre-built shared libraries or by Homebrew:
$ brew list ffmpeg | grep libavutil.*dylib
/usr/local/Cellar/ffmpeg/4.1.4_1/lib/libavutil.56.22.100.dylib
/usr/local/Cellar/ffmpeg/4.1.4_1/lib/libavutil.56.dylib
/usr/local/Cellar/ffmpeg/4.1.4_1/lib/libavutil.dylib
Now, your problem is that the libavutil (and ffmpeg) on your system is not backwards-compatible with your Mac 10.10. It was built targeting a newer Mac 10.12, which seems to have introduced changes to the clock_gettime API, causing the "Symbol not found" error. This has also been reported to the opencv-python issues:
This is not related to OpenCV. The error comes from libavutil
(=FFmpeg) which is installed via homebrew. The error is related to
binary backward compatibility (apparently Apple has changed the
libsystem interface). I'm not too familiar with Apples ecosystem but
building FFmpeg against earlier OS version might fix the issue if the
older symbols are present also in the latest OS versions. Full
backward compatibility on macOS might be impossible to achieve.
I was just bitten by this issue the hard way deep in nested
dependencies; FFmpeg targets 10.12 but I'm on 10.11. Hoping for a
fixed release soon.
Note that while downgrading Xcode may work too, the proper way to
target an earlier version of macOS is to add e.g.
-mmacosx-version-min=10.11 or -mmacosx-version-min=10.6 to CFLAGS/CXXFLAGS/LDFLAGS; this will tune headers, compiler and linker
to produce a binary that is compatible with at least that version of
macOS.
The only solution it seems, is to install an older version of ffmpeg (with libavutil) that is compatible with your Mac 10.10, and then tell OpenCV to link to that older version. You'll probably need to also build OpenCV from source (see Configure and Build OpenCV to Custom FFMPEG Install).
You can also try checking this post over at SuperUser:
Which ffmpeg package I should download for macOS?
Try installing the older ffmpeg#2.8 from Homebrew (though I'm not sure if that's going to work, I don't have a Mac 10.10 to test it on).
Try downloading pre-built static/shared builds from ffmpeg.org.
Try building it from source (see CompilationGuide/macOS)
I am running QGIS on Linux Fedora. Everything was fine until I upgraded to Fedora 29. Now, each time I launch QGIS or run a python script, I have the following message:
RuntimeError: the PyQt4.QtCore module failed to register with the sip module
after I import qgis._gui. I'm not sure what it means. Is it a problem with my sip version, some path to fix? I am running QGIS 2.18.20, sip-4.19.13 and Python 2.7.15.
Thanks
After unsuccessful debugging and googling about the very same issue, I've upgraded to 3.4 version from copr repository:
dnf copr enable dani/qgis
install qgis python3-qgis
Now python works and I can QGIS again, seems the developers are not too keen to solve 2.18 version errors.
I recently upgraded Linux Mint to 19.1 X64 with Python 3.6 from Linux Mint 18.3 X64 (with Python 3.5.2), and tried
from Crypto.Cipher import AES
I first got,
ImportError: No module named apt_pkg
fixed it by
sudo ln -s apt_pkg.cpython-{36m,35m}-x86_64-linux-gnu.so
in /usr/lib/python3/dist-packages;
then got another error,
ImportError: cannot import name '_AES'
I am wondering how to fix it. The interpreter for the project in PyCharm is currently set to Python 3.5.2;
Most likely, your PyCrypto installation is broken and _AES.dll is missing. The reason might be that your computer is 64 bit but the Crypto which is 32 bit was downloaded by pip. Try to reinstall it according to this question: How do I install PyCrypto on Windows?
Alternatively, you can download Crypto 64 bit from here: https://github.com/BConcernedOnFamily/Crypto_64bit with the fix and add the files my github downloaded to the corresponding location under your python3/Lib.
I am trying to build an app in PyQt5 (version 5.6+) in Python 3.6. It contains a web browser, using QtWebEngineWidgets.
It works fine on Mac, however, there are problems on Windows.
When I run the code on Windows and import the module:
from PyQt5 import QtWebEngineWidgets
I get the following error:
ImportError: cannot import name 'QtWebEngineWidgets'
Now, reading some forums it looks like PyQt5.QtWebEngineWidgets is not available for Windows, yet. Is it correct?
How can I have a web browser window, then?
I found online I could use QtWebKit, but according to here it seems QtWebKit was removed in Qt5.6.
So what? Do I have to downgrade PyQt version?
I can't go under 5.6 in Python 3.6 anyway. Do I have to change Python version as well?
you can try one of these solution ,
install old version :
pip install PyQt5==5.11.3
or install :
pip install PyQtWebEngine
u can download PyQt5.6 from here:
https://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.6
QtWebKit got deprecated upstream in Qt 5.5 and removed in 5.6. Beacuse The QtWebEngineWidgets module is better than QtWebkit.
The example directory has many examples about QtWebEngineWidgets
Yes, its possible to use QtWebEngineWidgets on Windows.