Problem using PySide / PyQt - python

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

Related

How can I import in Python simple coding error

I have started any coding for example: from PIL import Image, I encountered such an error:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
from PIL import Image
ModuleNotFoundError: No module named 'PIL'
I will be pleased that guide me.
In shell, run:
pip install Pillow
PIL is deprecated - Pillow is its replacement
This means that the package is not installed. To install it, you will need pip, a package installer for python.
Here is the Pillow package official website, which you can use to understand how to install the package: https://pillow.readthedocs.io/en/stable/installation.html. All the commands on the site are typed into Terminal on MacOS and Linux and the cmd on Windows.

ModuleNotFoundError though Python module PyBluez is installed

I am using python3 with the Thonny IDE. My programs are running on a Raspberry Pi 4B.
I tried to install PyBluez on different ways, with pip and with the built-in package installer of Thonny. Every time the installation seemed to work. When I then tried to import the module via import PyBluez I always get this error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pybluez'
But when I try to install it again I get these message, what I think mean, that it is already installed:
Requirement already satisfied: pyserial in /usr/lib/python3/dist-packages (3.4)
And the built-in package installer of Thonny shows me this message:
Installed version: 0.23
Installed to: /home/pi/.local/lib/python3.7/site-packages
Latest stable version: 0.23
Summary: Bluetooth Python extension module
Author: Albert Huang
Homepage: http://pybluez.github.io/
PyPI page: https://pypi.org/project/PyBluez/
Requires: pyobjc-core (<6,>=3.1), pyobjc-framework-Cocoa (<6,>=3.1), gattlib (==0.20150805) ; extra == 'ble'
But I still get the error that there is no module with this name.
I also tried to install the package PySerial on the same ways, but I ran into the same problem as with PyBluez. So it might be a general problem?
I haven't personally worked with that module, but after looking at the GitHub documentation, I can see that the import statement that is used is import bluetooth.
For example, on this page that's what they have
import bluetooth
import bluetooth._bluetooth as bluez
Consider using a different import statement

ImportError: PyQt4 is not installed

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.

can't install pyside and QT Mac OSX 10.9

I'm more or less new to python
I'm trying to install pyside and QT on a mac but I can't figure out how to install them.
I downloaded install files "pyside-1.1.0-qt47-py27apple.pkg" from http://qt-project.org/wiki/PySide_Binaries_MacOSX and "Qt libraries 4.8.5 for Mac" from http://qt-project.org/downloads.
double click on both files and installed. but it looks like it didn't work.
I can import PySide but nothing else.
in Python Idle when I type
import PySide
print PySide.__version__
1.1.0
then if I do:
import PySide.QtCore
I get this error.
Traceback (most recent call last): File "", line 1, in
import PySide.QtCore ImportError: dlopen(/Library/Python/2.7/site-packages/PySide/QtCore.so, 2): Library
not loaded: QtCore.framework/Versions/4/QtCore Referenced from:
/Library/Python/2.7/site-packages/PySide/QtCore.so Reason: no
suitable image found. Did find:
/Library/Frameworks/QtCore.framework/Versions/4/QtCore: mach-o, but
wrong architecture
I have python 2.7 and PyCharm. I also have installed setuptools and pip.
I looked around online and I see a lot of people had the same problem. but I couldn't find any answer that worked for me.
I hope anyone can help me out with this.
This worked for me:
sudo pyside_postinstall.py -install
Note: I'm using PySide 1.2.2, Qt 4.8.6, Mac OS X 10.9.3.
Edit: There is no more need to call the post-install script on Linux and MacOS systems since version 1.2.3 (2015-10-12).

Installing PySide on OSX 10.6.8

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

Categories

Resources