How can I use PyQt 4.x in Python 3.4? - python

I'd like to know how I can use PyQt 4.x in Python 3.4.4 on Windows XP(32bit).
I tried installing PyQt4-4.11.3-gpl-Py3.4-Qt4.8.6-x32.exe from this page.
I can command import PyQt4 and it doesn't show any error, but I can't import or use anything else. For example,
from PyQt4.QtGui import *
from PyQt4.QAxContainer import *
from PyQt4.QtCore import *
engenders only ImportError: DLL load failed: The specified module could not be found error.
Is Python 3.4.4 not compatible to PyQt4-4.11.3? I hope to get some help with it.

Related

ModuleNotFoundError: No module named 'System'

I'm working on an EXE file crypter in python 3.11.1 and I cannot seem to get the System.Reflection import working. I've tried pythonnet and clr, but it just doesn't recognize 'System.'
I've tried to make sure pythonnet and clr are not conflicting, but that hasn't worked either. I tried clearing the cache and reinstalling python entirely. I also made sure there weren't any multiple instances of pip and python. This is the code snippet:
def crypt(filepath):
import base64
import clr
from System.Reflection import Assembly

Can't import PyQt5.QtWebEngineWidgets

I'm trying to make an vocabtrainer for myself to get better in english, cause I suck. To achieve this, I'm trying to make a GUI with PyQt5 to expand my programming experience too :). But somehow I can't import the QtWebEngineWidget...
This is my code:
import PyQt5.QtWidgets as pyqtW
import PyQt5.QtGui as pyqtG
import PyQt5.QtCore as pyqtC
from PyQt5.QtWebEngineWidgets import *
import sys
class VocabTrainer:
def __init__(self):
self.main = pyqtW.QApplication([])
self.window = pyqtW.QWidget()
self.prepareWindow()
sys.exit(self.main.exec_())
def prepareWindow(self):
"""
Set's the attributes of the window.
"""
# window settings
self.window.resize(250, 100)
self.window.show()
def openPons(self):
"""
Opens the website of pons to be able to translate words.
"""
pass
test = VocabTrainer()
My IDE (PyCharm) warns me that it can't find the reference of PyQt5.QtWebEngineWidgets and if I run this code, I'll get this error message:
Traceback (most recent call last):
File "/A/little/path/VocabTrainer.py", line 12, in <module>
from PyQt5.QtWebEngineWidgets import *
ImportError: libQt5Quick.so.5: cannot open shared object file: No such file or directory
Process finished with exit code 1
I've installed the modules with the following commands:
pip install pyqt5
pip install pyqtwebengine
I've also tried to reinstall the modules but without success.
Python-Version: 3.8.1
OS: Arch Linux
In the case of ArchLinux, having the most up-to-date packages, I generally recommend using the repository packages (IMHO Arch Linux is a good laboratory to test the new functionalities :-)). Considering the above, I recommend installing pyq5 and pyqtwebengine by running the following:
sudo pacman -S python-pyqt5 python-pyqtwebengine
You must also change the python that pycharm uses to the system.

Python 3.4.3 + Current PyQt5, DLL load failed

When trying to run a simple test of a database.py:
import pymysql.cursor
from PyQt5.QtCore import pyqtSignal, QObject, QTimer
This the output in the Exceptions tab of WingWare IDE:
File "c:\MyProjects\___MECHANIKOS\UltraSimpleSarlaccPit\01_UltraSimpleSarlaccPit.py", line 1, in <module>
from database import Database
 File "c:\MyProjects\___MECHANIKOS\UltraSimpleSarlaccPit\database.py", line 2, in <module>
from PyQt5.QtCore import pyqtSignal, QObject, QTimer
builtins.ImportError: DLL load failed: The specified module could not be found.`
There was an error when installing PyQt5 that says it was built for 3.5 not 3.4. So is that why?
If so, where can we download a 3.4.3 compatible version?
Thanks!
Regards,
Team Mechanikos
Try upgrading to 3.5:
Uninstall old PyQt5 and Python 3.4.3 through control panel > Programs
Install python 3.5.1, specifying making sure you specify C:\Python35\ as install location.
Install PyQt5 for 3.5 (Current).
Works.

How do i convert a python3.4 script(that has installed modules) into a windows executable using py2exe?

I have a python script that i have to import all these modules, which some of them require downloading:
import datetime
from dateutil import parser
from tkinter import filedialog
import tkinter
import mailbox
import pprint
import json
import urllib.request
from tkinter import *
Is there a way, using py2exe, i can convert the script into a windows executable. If so, how?
To simplify the procedure, you will want to have all your modules already downloaded. This can be accomplished with a simple "pip install " from command prompt. Then it is as simple as writing and running a setup.py file - detailed directions for how to do this can be found here.

Python: from import error

I'm running Python 2.6.6 on Ubuntu 10.10.
I understand that we can import a module and bind that module to a different name, e.g.
import spam as eggs
also,
from eggs import spam as foo
My problem is that when running the PySide examples, the following import code does not run:
import PySide as PyQt4
from PyQt4 import QtCore, QtGui
It generates an import error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PyQt4
Clearly, according to the Python interpreter the above code is incorrect, my question is why is it incorrect or rather why doesn't this work?
import and from are a special syntax.
They look for a module name, which means a file in sys.path which starts with the module name.
And it seems like you don't have PyQt4 installed, so it will fail.
The fact that you have a variable called PyQt4 in your namespace after running import PySide as PyQt4 does not change anything, Python is still looking for an actual module called PyQt4 when you do from PyQt4 import QtCore, QtGui.
Try doing
import PySide as PyQt4
QtCore = PyQt4.QtCore
QtGui = PyQt4.QtGui
or
import PySide as PyQt4
from PySide import QtCore, QtGui
That should be equivalent.
I just installed PySide and was doing a tutorial where all the examples used PyQt4. I got tired of changing the imports from PyQt4 to PySide so I just made a symlink in my site-packages, using the following steps:
1) There's surely a better way but I found where my python packages were installed by opening a shell and running python, then at the interactive interpreter typed:
>>> import sys
>>> print sys.path
2) I then found PySide in one of the directories and cd'd to it (n.b. It's at /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages if you're using the macports PySide install for python 2.7 on Mac OSX Leopard 10.5.8).
3) Then I made a symlink with ln, in my case I had to use sudo:
sudo ln -s PySide PyQt4
That's it, now I can just use:
from PyQt4 import QtGui
as normal - happy days!
Obviously, if you ever want to install PyQt4 you should rm the PyQt4 symlink first.
Another caveat: What I've described above may well be wrong/bad in many ways - I am no expert at Python installs but so far it's ok for me. YMMV so use at your own risk. Hopefully someone will comment soon to say "no, very bad!" or ideally "yeah don't sweat it, we cool.."

Categories

Resources