I installed PyQt5 using brew install pyqt5 which worked. I am using Python 3.7.1 which was also installed using brew.
When I execute a Python script where i used from PyQt5.QtCore import Qt I get the following error message:
Traceback (most recent call last):
File "app.py", line 15, in <module>
from PyQt5.QtCore import Qt
ModuleNotFoundError: No module named 'PyQt5'
Is there something else I need to to so I can use PyQt in Python?
I didn't get this to work when trying to install pyqt5 using homebrew. Instead, I just used pip to install it with the following command pip3 install pyqt5.
Related
Ok so I'm trying to install pyglet using pip3 and I've used the command pip3 install pyglet and it works it's in my /usr/local/lib/python3.7/site-packages (1.4.9) and I am using python 3.7. I have successfully imported things using pip before, I've tried uninstalling and reinstalling... I'm not sure what the problem is the error message is
Traceback (most recent call last):
File "/Users/myname/Documents/plz.py", line 1, in <module>
import pyglet
ModuleNotFoundError: No module named 'pyglet'
I'm currently using Ubuntu 18.04 LTS.
I'm trying to install a program that need PyQt4 and QtWebKit, so a manual installation is necessary as QtWebKit have been excluded from PyQt4.
I downloaded sip 4.19.12 (with 4.19.14 installation of PyQt4 fails) and PyQt4 4.12.13
I ran a virtualenv, made sure it was working as intended and tried installing sip, which works:
$ python configure.py
$ make
$ make install
Then I proceed with the same with PyQt4, with no errors.
When I try to run my program .py, it gives the following error:
$ python RNAEditor.py
Traceback (most recent call last):
File "RNAEditor.py", line 9, in <module>
from Helper import Helper, Parameters
File "/home/bioinfo/Documentos/Ferramentas_RNAEditor/RNAEDITOR_ch/Helper.py", line 13, in <module>
from PyQt4 import QtCore
ImportError: No module named sip
$ sudo python RNAEditor.py
Traceback (most recent call last):
File "RNAEditor.py", line 9, in <module>
from Helper import Helper, Parameters
File "/home/bioinfo/Documentos/Ferramentas_RNAEditor/RNAEDITOR_ch/Helper.py", line 13, in <module>
from PyQt4 import QtCore
ImportError: No module named PyQt4
I'm sure that my virtual env does have sip and PyQt4, as importing both within virtualenv/python gives no error too.
$ python
>>> import PyQt4
>>> import sip
>>> from PyQt4 import QtCore
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named sip
Any ideas on how to set PyQt4 and sip with a manual installation, or why it is not working as intended?
PyQt started from version 4.12.2 needs private sip module called PyQt4.sip (see file NEWS in PyQt 4 source folder)
So you should configure sip using this command:
python configure.py --sip-module PyQt4.sip
After sip is built, you should copy file sip.pyd to PyQt4 python directory - by default it is c:\python27\Lib\site-packages\PyQt4
I got it to work with specific SIP and PyQt4 versions and running inside a virtualenv. I have no idea what happens, but it seems that in Ubuntu 18.04 something happens with the last versions of PyQt4 and SIP and they do not work as intented, but they do work in Ubuntu 16.04 (tested).
The code that worked in Ubuntu 18.04 is:
PYQT4 4.12.1 and sip 4.19.12
sudo apt-get install python-pip python2.7-dev libxext-dev python-qt4 qt4-dev-tools build-essential
pip install virtualenv
virtualenv PROJECTNAME
source PROJECTNAME/bin/activate
cd SIP_SOURCE_DIRECTORY
python configure.py
make
make install
cd PYQT4_SOURCE_DIRECTORY
python configure.py
make
make install
Then you have your virtualenv where QtWebKit is supported, which is important for many applications
I try to use the py_entitymatching framework to find duplicates in this dataset.
To label the data it uses PyQt4.
So when I try to execute the labeling command I get an error
Though as you can see PyQt4 is installed on my machine and I can import it.
Any ideas on how to fix it?
Thanks
Update:
When I try to import QtGui I get the following error:
>>> from PyQt4 import QtGui
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /home/oliver/anaconda3/lib/python3.5/site-packages/PyQt4/QtCore.so: undefined symbol: __cxa_throw_bad_array_new_length
All the packages mentioned below have been installed
Qt4
SIP
PyQt4
PyQt5
Any other thoughts?
It looks like your PyQt package is not installed, even if the first line says that your package is installed.
Try to install it with pip and see if it does make a change
If you are using python2
sudo pip install SIP
sudo pip install PyQt
If you are using python3
sudo apt-get install python3-pyqt4
Update
from PyQt4 import QtGui
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /home/oliver/anaconda3/lib/python3.5/site-packages/PyQt4/QtCore.so: undefined symbol: __cxa_throw_bad_array_new_length
Looking at your error, it seems your compilation did go wrong.
One possible solution would be to deinstall python, reinstall it and install PyQt again through pip
The same problem happened to me, you need to install the 64-bit version of pyqt4. you can install it here.
Once you install it correctly I think it will work correctly.
Trying to get my feet wet with PySide development but having trouble
getting setup. I tried installing the binaries 1.0.4-r1 and 1.0.5 but
both of those produced the following message on import PySide
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.6/site-packages/PySide/__init__.py", line 2,
in <module>
import private
File "/Library/Python/2.6/site-packages/PySide/private.py", line 2,
in <module>
from QtCore import __moduleShutdown
ImportError: dlopen(/Library/Python/2.6/site-packages/PySide/
QtCore.so, 2): Library not loaded: QtCore.framework/Versions/4/QtCore
Referenced from: /Library/Python/2.6/site-packages/PySide/QtCore.so
Reason: image not found
Then I tried doing the install from the gitorious build scripts. Using
sudo ./dependencies.osx.sh. After that completed I now get the
following error on import PySide.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.6/site-packages/PySide/__init__.py", line 2,
in <module>
File "/Library/Python/2.6/site-packages/PySide/private.py", line 2,
in <module>
ImportError: No module named QtCore
Any advice is appreciated. I'm using QtCreator 2.2.1 and Qt SDK
1.1.2 / Qt Library 4.7.3. Thank you!
Try to install latest version MacPorts and python 2.7 first and set python2.7 as default python version:
sudo port install python27
port select --list python
sudo port select --set python python27
then re-install PySide again:
sudo port install py27-pyside
I just encountered exactly the same problem:
Library not loaded: QtCore.framework/Versions/4/QtCore
You need to find installed QT libraries and make them visible to the dynamic linker.
My Qt*.framework folders live in /usr/local/lib (Qt is installed with Homebrew package manager). So, I added
export DYLD_FRAMEWORK_PATH=/usr/local/lib:$DYLD_FRAMEWORK_PATH
to ~/.bash_profile and restarted the console.
That's it.
I just solved the same problem by using homebrew to install pyside.
$ sudo -H pip uninstall pyside
$ brew install pyside
I'm trying to install PySide to use the Qt libraries for scraping a website. I was following the instructions on this site and installed PySide using MacPorts (py26-pyside).
This command:
from PySide.QtCore import *
Works fine. But:
from PySide.QtGui import *
gives me this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PySide/QtGui.so, 2): Library not loaded: /opt/local/lib/libpng12.0.dylib
Referenced from: /opt/local/lib/libQtGui.4.dylib
Reason: Incompatible library version: libQtGui.4.dylib requires version 45.0.0 or later, but libpng12.0.dylib provides version 44.0.0
I've tried updating any old ports and reinstalling libpng through MacPorts, but no luck.
Any ideas what I need to do?
It not a good idea mix use system build-in python(version 2.6) and PySide install by manual.
I got the same problem before and fix it after upgrade to py27-pyside.
please try py27-pyside via MacPorts
sudo port install py27-pyside