Error with dll when importing Qt Desktop Components for PySide - qml

I am trying to get Qt Quick Desktop Components to work with PySide 1.1.2 and Python 2.7. So far, I have compiled the latest version of the Desktop Components with MSVC in release mode and copied the components folder, containing both the .qml files and plugin/styleplugin.dll, to Python\Lib\site-packages\PySide\imports\QtDesktop.
Here is my current code:
import sys
from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtDeclarative import QDeclarativeView
app = QApplication(sys.argv)
view = QDeclarativeView()
view.setSource(QUrl('server.qml'))
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
view.show()
sys.exit(app.exec_())
My Qml file:
import QtQuick 1.1
import QtDesktop 0.1
Window {
}
The error I am getting:
file:///C:/Programming/CibAbi/server.qml:15:1: plugin cannot be loaded for module "QtDesktop":
Cannot load library C:/Programming/Python27_32bit/Lib/site-packages/PySide/imports/QtDesktop/plugin/styleplugin.dll:
The specified procedure could not be found.
import QtDesktop 0.1
^
Does anybody know of a way to fix this, or does anyone have more specific steps on using the Desktop Components with PySide? Thank you. :)

Edit your system PATH variable so that the PySide directory appears in the path before any PyQt or other Qt directory.
http://qt-project.org/wiki/PySide_FAQ#6624847b60a84a6d81a5950805dfb6df

works perfectly
pyside py 3.3 32 Bit
Qt libraries 4.8.5 for Windows (VS 2010)
config release and build
rename folder "component" to "QtDesktop"
copy this folder en pyside/imports/
and Guala

Related

Installed modules not found, but show up in python interpreter config

I tried to install EZGmail module for Python. When I check my interpreter settings, it shows it as installed in the PyCharm list. I then use this same interpreter for my project, but I get a module not found error when trying to import EZGmail. What should I check?
Looks like you're trying to import the module in a different casing than it's mentioned on the document.
You're trying to do:
import EZGmail
while the Quickstart document says:
import ezgmail

QWebEngineView not working with PyInstaller

I'm getting a "blank canvas" when using PyInstaller to package and application that utilizes QWebEngineView. Any help would be greatly appreciated!
Here's some code to reproduce the problem...
The following code runs fine with python:
import sys
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtCore import QUrl
if __name__ == '__main__':
app = QApplication(sys.argv)
view = QWebEngineView()
view.resize(1024, 600)
view.load(QUrl('http://www.google.com'))
view.show()
sys.exit(app.exec_())
but after packaging with pyinstaller toy.py nothing is shown.
The python application shows:
while the pyinstaller application shows:
So this appears to be a bug in pyinstaller that can be patched by creating a specific file for PyQt.
The first clue in debugging this problem is to take note that QtWebEngineProcess.exe starts (as seen in the Task Manager) when we start from python, but it does not start with our application with pyinstaller. Upon inspection a log is written next to the pyinstaller copy of the QtWebEngineProcess.exe that doesn't really give a helpful message, but it does give a clue that the *.exe was attempted to start and crashed.
It appears that adding a qt.conf to dist/<app>/PyQt5/Qt/bin with the contents
[Paths]
Prefix = ..
fixed my problem.

Deploy Qt3D project for Android under win 7

I've successfully deployed the cube example APK by creating a new Quick 2 project and copy qml file there, but got "module "Qt3D" plugin "qthreedqmlplugin" not found" error message, any clue for this? I already place the so file into imports/Qt3D folder, but no success. Thanks.
Edit: I tried using Qt 5.1.1 and followed the Qt3D installation described here (http://qt-project.org/wiki/Qt3D-Installation) , and can get rid of the plugin not found error message above. But, this time, a message of “library “libQt53DQuick.so” not found” show up as follows:
W/Qt (29930): assets:/qml/3dCube/main.qml:2 (): assets:/qml/3dCube/main.qml:2:1: plugin cannot be loaded for module "Qt3D": Cannot load library /data/data/org.qtproject.example.test3D/qml/Qt3D/libqthreedqmlplugin.so: (Cannot load library: soinfo_link_image(linker.cpp:1635): could not load library "libQt53DQuick.so" needed by "libqthreedqmlplugin.so"; caused by load_library(linker.cpp:745): library "libQt53DQuick.so" not found)
The problem been solved! After adding the following line in my .pro file:
QT += qml quick 3dquick
The example works well in my sony android phone with adreno gpu, but not in my new lenovo yoga 8" with PowerVR gpu which I'll look into later.
Edit: BTW I eventually use QT5.2.1 for building my example.
That's because in Qt 5.3 there was no way to figure out the plugin dependencies of qml imports. In 5.4, we have the qml import scanner that avoids the need to edit your .pro files to mention qml import dependencies.

Py2Exe and MatPlotLib: Plot won't Appear

I have a working Python 2.6 code using matplotlib, and would like to get a working exe out of it. I am having problems getting this accomplished:
Initially I got an error for missing MSCVP90.dll, but I downloaded that and extracted the .dll to the working directory and that error went away.
I had some errors regarding a missing tkagg module, but I added that to the exceptions and edited the matplotlibrc file to default to WXAgg instead and that went away.
The exe runs normally, but at the end of the code it is supposed to display a plot, and it doesn't. The plot is the main goal of this program, so it would be good to have this.
Just running the python code brings the plot up just fine.
Can anyone offer any suggestions or insights?
Here's my setup.py:
from distutils.core import setup
import py2exe
import matplotlib
matplotlib.use('wxagg') # overrule configuration
import pylab
setup(
console=['test1.py'],
options={
'py2exe': {
'excludes': ['_gtkagg', '_tkagg', 'backend_tkagg'],
}
},
data_files=matplotlib.get_py2exe_datafiles(),
)
Thanks in advance!
Alright, I used pyinstaller and reverted the matplotlibrc file back to its original state where TkAgg was the default and everything works on my computer, but when I try to run it on another computer the plot still does not appear...
I can use pyinstaller to compile an exe out of a very simple matplotlib code, like:
from pylab import *
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plot(t, s, linewidth=1.0)
show()
But when I take that exe to another computer, it does not work.
Has anyone else had a similar issue? Any ideas?
Thanks
If the executable runs in your computer but doesn't work in another computer, the most likely problem is the lack of one or more of the required dlls that py2exe doesn't pack because license problems.
Very often these dlls are
gdiplus.dll
msvcp90.dll
Look for them in the computer where the exe works and copy them to the failing computer.
If the exe still doesn't work, check for other dll's. Py2exe gives the list of binary dependencies:
*** binary dependencies ***
Your executable(s) also depend on these dlls which are not included,
you may or may not need to distribute them.
Make sure you have the license if you distribute any of them, and
make sure you don't distribute files belonging to the operating system.
OLEAUT32.dll - C:\Windows\system32\OLEAUT32.dll
USER32.dll - C:\Windows\system32\USER32.dll
gdiplus.dll - gdiplus.dll
SHELL32.dll - C:\Windows\system32\SHELL32.dll
ole32.dll - C:\Windows\system32\ole32.dll
RPCRT4.dll - C:\Windows\system32\RPCRT4.dll
WSOCK32.dll - C:\Windows\system32\WSOCK32.dll
WINMM.dll - C:\Windows\system32\WINMM.dll
ADVAPI32.dll - C:\Windows\system32\ADVAPI32.dll
msvcrt.dll - C:\Windows\system32\msvcrt.dll
WS2_32.dll - C:\Windows\system32\WS2_32.dll
WINSPOOL.DRV - C:\Windows\system32\WINSPOOL.DRV
GDI32.dll - C:\Windows\system32\GDI32.dll
IMM32.dll - C:\Windows\system32\IMM32.dll
MSVCP90.dll - C:\Python26\programas\test\MSVCP90.dll
KERNEL32.dll - C:\Windows\system32\KERNEL32.dll
ntdll.dll - C:\Windows\system32\ntdll.dll
COMCTL32.dll - C:\Windows\system32\COMCTL32.dll
COMDLG32.dll - C:\Windows\system32\COMDLG32.dll
VERSION.dll - C:\Windows\system32\VERSION.dll
C:\Python26\programas\test>
Finally, I succesfully got a functional matplotlib program executable with py2exe. I only needed to add an 'includes' to setup.py and set WXAgg as the backend in matplotlib.rc (with Tk I got the same problem you described...). For it to work, I had to set WXAgg in the original matplotlib.rc (in the matplotlib/mpl-data folder). This is the one py2exe imports (not the one in the user's matplotlib configuration directory). To be sure check the .rc file in your dist folder.
from distutils.core import setup
import py2exe
import matplotlib
setup(
console=['test1.py'],
options={
'py2exe': {
'excludes': ['Tkconstants','Tkinter', 'tcl'],
'includes': ['matplotlib.backends.backend_wxagg'],
}
},
data_files=matplotlib.get_py2exe_datafiles(),
)
Today I lost one day of work with this, so...
The solution is to include "FileDialog" module explicity, because the "six" module uses it. Specifically, I solved my problem by including six, dateutil, FileDialog, matplotlib, pylab, matplotlib.backends.backend_tkagg and others.
Good Luck!

Use glade with pygobject Gtk3

I am converting a script to use Gtk3 using the migration guide (Porting GTK2 to GTK3). I converted my import pygtk to a from gi.repository import Gtk and so on...
I'm stuck because the glade module was loaded from module gtk:
import gtk
import gtk.glade
but there's no way now to do that anymore.
Note that I would only need a replacement for gtk.glade.XML()...
Well, the solution is pretty obvious, after calling to Gtk.Builder() one needs to convert the old glade interface with the gtk-builder-convert command to get the interface file in the right version.
$ gtk-builder-convert myui.glade myui.ui
And then, in the python script:
from gi.repository import Gtk
builder = Gtk.Builder()
builder.add_from_file("myui.ui")
Thanks to Riccardo.
This should work
from gi.repository import Gtk
builder = Gtk.Builder()
builder.add_from_file("project.xml")