ImportError: cannot import name QtWebKit when using PySide - python

I am trying to get my old project clipmanager building and I am encountering the following error:
/home/user/.virtualenvs/clipmanager27/bin/python /home/user/development/clipmanager/clipmanager/app.py
Traceback (most recent call last):
File "/home/user/development/clipmanager/clipmanager/app.py", line 15, in <module>
from mainwindow import MainWindow
File "/home/user/development/clipmanager/clipmanager/mainwindow.py", line 12, in <module>
import dialogs
File "/home/user/development/clipmanager/clipmanager/dialogs.py", line 8, in <module>
from PySide import QtWebKit
ImportError: cannot import name QtWebKit
Process finished with exit code 1
I installed Pyside with pip install pyside. I do not even see QtWebKit.so in the site packages folder /home/user/.virtualenvs/clipmanager27/lib/python2.7/site-packages/PySide:
Did it get removed due to licensing?

For Arch Linux, install qt4 and also qtwebkit before installing PySide.

Related

Sphinx Qt ValueError: API 'QDate' has already been set to version 1

I am trying to use python's Sphinx module to build a documentation for a Qgis (pyqt) plugin (using Pyqt). When trying to build withmake html,
I get several exceptions for some modules all being :
ValueError: API 'QDate' has already been set to version 1
Here is the full stack
home/user/path/project.rst:105: WARNING: autodoc: failed to import module u'new_project_base'; the following exception was raised:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/sphinx/ext/autodoc.py", line 551, in import_object
__import__(self.modname)
File "/home/rescue/bathydeconfliction/new_project_base.py", line 14, in <module>
from qgis.core import QgsProject
File "/usr/lib/python2.7/dist-packages/qgis/__init__.py", line 26, in <module>
from qgis.PyQt import QtCore
File "/usr/lib/python2.7/dist-packages/qgis/PyQt/QtCore.py", line 28, in <module>
sip.setapi(api, 2)
ValueError: API 'QDate' has already been set to version 1
What am I doing wrong? (Using python 2.7, sphinx 1.5.2 on Debian Jessie)
importing qgis.core before importing PyQt4 has fixed it for me
import qgis.core
from PyQt4 import QtCore, QtGui, uic
qgis isn't part of pyqt but the error occurs when you try to use qgis APIs along with PyQt in the same code. I believe, the reason is qgis defines QDate which conflicts with QDate in PyQt4

Anki error on Ubuntu 16.10

Here's what I'm getting when I try to run anki from the command line: `
Traceback (most recent call last):
File "/usr/bin/anki", line 5, in <module>
import aqt
File "/usr/share/anki/aqt/__init__.py", line 12, in <module>
from aqt.qt import *
File "/usr/share/anki/aqt/qt.py", line 22, in <module>
from PyQt4.QtWebKit import QWebPage, QWebView, QWebSettings
ImportError: No module named QtWebKit
“anki &” has ended`
Looking at my system I do notice I have a PyQt5.QtWebKit installed ( or something like that ) while here's asking for PyQt4. How do I reconcile ?
I finally managed to properly install PyQt4 based on these instructions : https://blog.qtibia.ro/2016/06/21/build-python-qt4-on-debian-testing/ And now I got anki running properly.
I also ran into this issue on Ubuntu MATE 17.04. The best solution I've found is to install the compiled version of Anki from their website -> https://apps.ankiweb.net/#linux since it bundles all the required libraries.

pyplot import raises ImportError

I am having a strange problem tryin to import matplotlib. Whenever I do the import
import matplotlib.pyplot as plt
I get the following error message (When just importing matplotlib there is no error:
Vendor: Continuum Analytics, Inc.
Package: mkl
Message: trial mode expires in 30 days
Traceback (most recent call last):
File "C:\Users\Pierre\Anaconda3\lib\site-packages\matplotlib\backends\qt_compat.py", line 159, in <module>
from PySide import QtCore, QtGui, __version__, __version_info__
ImportError: No module named 'PySide'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/Pierre/Dropbox/piR/Coding/Python/Eigene Projekte/GPX_reader/main.py", line 6, in <module>
import matplotlib.pyplot as plt
File "C:\Users\Pierre\Anaconda3\lib\site-packages\matplotlib\pyplot.py", line 114, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "C:\Users\Pierre\Anaconda3\lib\site-packages\matplotlib\backends\__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "C:\Users\Pierre\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt4agg.py", line 18, in <module>
from .backend_qt5agg import FigureCanvasQTAggBase as _FigureCanvasQTAggBase
File "C:\Users\Pierre\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt5agg.py", line 15, in <module>
from .backend_qt5 import QtCore
File "C:\Users\Pierre\Anaconda3\lib\site-packages\matplotlib\backends\backend_qt5.py", line 31, in <module>
from .qt_compat import QtCore, QtGui, QtWidgets, _getSaveFileName, __version__
File "C:\Users\Pierre\Anaconda3\lib\site-packages\matplotlib\backends\qt_compat.py", line 162, in <module>
"Matplotlib qt-based backends require an external PyQt4, PyQt5,\n"
ImportError: Matplotlib qt-based backends require an external PyQt4, PyQt5,
or PySide package to be installed, but it was not found.
I use Python 3.5 in the Anaconda distribution on Windows 10. Anybody run into the same problem? The only recent change in the my setup was the (forced) upgrade to Windows 10...
Thanks and best wishes
Pierre
You don't have PySide or PyQt installed, the Error Message is clear about that as matplotlib depends on either one of them
To install PySide run
pip install -U PySide
from the command line the -U stands for upgrade and means upgrade all packages you have installed to the newest version
from the man page of pip
-U, --upgrade
Upgrade all packages to the newest available version. This
process is recursive regardless of whether a dependency is
already satisfied.
but you should be just fine doing
pip install PySide
if for some reason you don't want to upgrade other packages installed by pip

Why can't I import PyQt in Python files?

I have installed PyQt using brew but when I am trying to import it, I just receive errors as follows:
>>> from PyQt4 import QtCore, QtGui
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PyQt4
>>> from PyQt5 import QtCore, QtGui
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PyQt5
Here's the command I used in terminal for installing PyQt in OSX:
brew install python qt pyqt pyside pyside-tools
Any idea what's gone wrong?
The most painless way to do python without messing around with modules is to install distributions. Two very good ones are Canopy Python and Anaconda. They have most, if not all, modules you are going to need for production. Pyqt and pyside are included in both of these distributions.

PyQt4 QtCore.so symbol not found error

I installed sip and PyQt but when i execute a python code like python tutorial.py , take this error. I installed pyqt with brew install and configure.py both.
Traceback (most recent call last):
File "untitled.py", line 4, in <module>
from PyQt4 import QtCore, QtGui
ImportError: dlopen(/Library/Python/2.7/site-packages/PyQt4/QtCore.so, 2): Symbol not found: __ZN10QArrayData11shared_nullE
Referenced from: /Library/Python/2.7/site-packages/PyQt4/QtCore.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/PyQt4/QtCore.so
I Solved this problem with delete Python and installing python and pyqt with macPorts.

Categories

Resources