After installing PyQt using brew install, like so:
brew install qt
brew install sip
brew install pyqt
I try to run a sript and I get this error:
Traceback (most recent call last):
File "exampleosx.py", line 17, in <module>
from PyQt4 import QtGui
ImportError: dlopen(/Library/Python/2.7/site-packages/PyQt4/QtGui.so, 2): no suitable image found. Did find:
/Library/Python/2.7/site-packages/PyQt4/QtGui.so: mach-o, but wrong architecture
I've tried following many tutorials on how to run the code with different options but with no luck.
Adding "arch -i368" is not fixing the problem either.
I'm using OSX 10.7.5 and Python 2.7.1
Try running your script with this prefix.
VERSIONER_PYTHON_PREFER_32_BIT=no /usr/bin/python exampleosx.py
Try running your script with $arch -i386 in front on the command line, something like :
$arch -i386 python myscript.py
Because Pyqt is available for 32 bits architecture only.
Related
I use this tutorial text as an example, there are others:
#!/usr/bin/python
import MySQLdb
If it produces the following result, then it means MySQLdb module is not installed −
Traceback (most recent call last):
File "test.py", line 3, in <module>
import MySQLdb
ImportError: No module named MySQLdb
To install MySQLdb module, use the following command −
For Ubuntu, use the following command -
$ sudo apt-get install python-pip python-dev libmysqlclient-dev
I have gone trough these steps, more or less as described above.
Problem is that the subdirectory "python" does not exist under /usr/bin/
in my file system. I run Linux Mint 18.3. Python 2.7 seems to be the native version installed in Mint (used for several purposes), but I have also installed Python 3.6.4 and wish to use this for development purposes.
Does anyone know in which directory I could expect to find MySQLdb?
Since #!/usr/bin/python is non existent I wonder - has MySQLdb been properly installed? If it has, I have not after several efforts succeded in locating it.
I want to import the vlc from my python script, but it is getting error like follows:
Traceback (most recent call last):
File "test.py", line 3, in
import vlc
ImportError: No module named vlc
How to solve this problem??
For people stumbling upon this answer in 2020 and using Debian Linux, try the following command:
sudo pip3 install python-vlc
looks like your files are not on "sys.path", from where usually python tries to pick up imports
Try and access from interpreter. just type "import vlc" and see if that works.
If it does't work then just copy your vlc module files (I guess its vlc.py) to your python sys.path location and try again
go through these links, it may help
https://docs.python.org/2/using/cmdline.html#environment-variables
https://docs.python.org/2/library/sys.html#sys.path
Try to use pip install python-vlc in command prompt (if you are using windows). This will remove that error, as vlc is not yet installed on your system.
If you are using Ubuntu or other Linux Kernel OS, then first install pip (and python) on your system using whatever your package manager is (if necessary), then do pip install python-vlc.
I've followed the instructions on:
http://danmarner.com/2014/04/23/Installing-PyQt5-with-Python-3-On-OS-X.html
to first install SIP according to the instructions found at:
http://pyqt.sourceforge.net/Docs/sip4/installation.html
and then PyQt5 by following the instructions found here:
http://pyqt.sourceforge.net/Docs/PyQt5/installation.html
and then brew install qt5
but when I run the first example PyQt-gpl-5.3.2/examples/tutorials/addressbook/part1.py it fails with the following:
Traceback (most recent call last):
File "examples/tutorials/addressbook/part1.py", line 45, in <module>
from PyQt5.QtCore import Qt
ImportError: No module named PyQt5.QtCore
I'm running Mavericks 10.9.5 and Python 2.7.5
It doesn't seem like it's installed correctly, or if it is python can't find it. I'm not sure how to proceed so any suggestions are much appreciated!
The issue was resolved by adding /usr/local/lib/python2.7/site-packages to PYTHONPATH. Thanks to the comments found here:
https://stackoverflow.com/a/13103438/1729686
and to #Kash and #qqvc for the suggestions!
if you used brew, you can add into .bashrc
export PYTHONPATH=$(brew --prefix)/lib/python3.6/site-packages:$PYTHONPATH
(edit python3.6 to your python version).
And next, reload bash and run
echo $PYTHONPATH
if response not null, thats ok
I'm trying to use PySide so I did a brew install pyside pyside-tools. However, I get the following error:
>>> from PySide.QtGui import QApplication
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Python/2.7/site-packages/PySide/QtGui.so, 2): Library not loaded: QtGui.framework/Versions/4/QtGui
Referenced from: /Library/Python/2.7/site-packages/PySide/QtGui.so
Reason: image not found
This SO question says to install python 27 and then reinstall pyside but I'm using the native python on mac osx 10.8 and it is already 2.7.2.
The Homebrew recipe for PySide seems to indicate that this should have been fixed but I'm still getting the errors. I made sure libpng is installed as well.
Looking at the path, I know that the QtGui.so file is there. Since I'm new to Python, PySide, and Qt, it is hard for me to Google and further troubleshoot.
If anyone knows why and can provide directions, I will be very grateful. It can involve uninstalling a bunch of stuff and reinstalling. Please give detailed instructions. I did uninstall and try to reinstall and got the same result.
Thank you.
I was getting the same error, and I'm using Python installed via Homebrew. I found two PySide libraries in /Library/Python/2.7/site-packages/ . Moving them out of the way, and re-building/installing PySide through Homebrew worked.
I tried the import you gave - I am using same system environment. It worked fine. try: brew update and re-install.
Got the same error when running ipython qtconsole which will import PySide to provide a Qt console.
Finally I thought there might be something wrong after PySide's installation. So I run pyside_postinstall.py -install manually which should be automatically run after PySide is installed, and this fixed my problem. Hopes working for your too!
I'm following a tutorial of making desktop apps. with python and qt4, I downloaded and installed qt creator ide, created the .ui file and then I had to convert it using pyuic4, I've been trying a lot of things and still can't do it.
I thought that pyuic4 would be installed with Qt creator IDE, but it seems that's not the case, so I installed pyqt through macports:
sudo port install py26-pyqt4
I didn't know but that came with qt, so it was about 3 hours building it.
after installing it I tried to convert the .ui again:
$ pyuic4-2.6 principal.ui -o prin.py
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PyQt4/uic/pyuic.py", line 4, in <module>
from PyQt4 import QtCore
ImportError: No module named PyQt4
No module named PyQt4? wasn't that what I just installed?
Thanks, and excuse me if my english isn't 100% good.
I've solved it, you have to use the python of macports instead of the default that comes with OS X, to do that install python_select through macports:
sudo port install python_select
sudo python_select python26
I made some notes on building and install PyQt4 on Mac Snow Leopard.
The order is important, and there are some quirks with 64-bit libraries. The default Mac Qt libs are Carbon (32 bit), whereas Mac system Python is 64 bit and needs the Cocoa libs.
I spent a while finding the package name in Homebrew. It seems to be:
brew install pyqt