Error in my first Qt5 program
-
@SGaist I did not check. How can I check if python3 is from my virtual environment?
-
Run
which python3
in the terminal you use to execute your script. -
That gave me ~/.nitin_venv/bin/python. So, I think python is from my virtual environment. Also, Do I have to run the my python program from my virtual environment?
-
The file doesn't need to be in there, the virtual environment is there to provide you with the dependencies you need in a controlled fashion.
Can you show the code you are using to test that ?
-
Sure.
Here it is!from PyQt5.QtWidgets import *
import sys
app = QApplication([])
label = QLabel('Hello world!')
label.show()
app.exec_() -
@Mikenitin92
If your problem seems to be something about not being to find libraries such that Qt apps can't be run then this probably has nothing to do with it. But I don't think you can write a Qt app to just "display a label nowhere" as per your code (you need a window or a dialog etc.). Did you get this code from somewhere/do you have a problem when it runs, or are you still at the ImportError just trying to get going? -
Hi,
I have tested with a new sample file which is:
print ("Hi")
from PyQt5.QtWidgets import *And this is the output:
Hi
Traceback (most recent call last):
File "/Users/Nitin/PycharmProjects/pluralsight/nitin_venv/lib/test.py", line 2, in <module>
from PyQt5.QtWidgets import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyQt5/QtWidgets.so, 2): Symbol not found: __os_activity_create
Referenced from: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyQt5/Qt/lib/QtCore.framework/Versions/5/QtCore (which was built for Mac OS X 10.12)
Expected in: /usr/lib/libSystem.B.dylib
in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyQt5/Qt/lib/QtCore.framework/Versions/5/QtCore -
@Mikenitin92 said in Error in my first Qt5 program:
import sys
app = QApplication([])Unrelated but to be clean, it should be
sys.argv
as parameter of QApplication.What version of PyQt do you have installed ?
Did you try to uninstall your system version of PyQt and re-install it in your virtual environment ? -
Hello,
I have PyQt5. I have deleted the virtual folder and created it again, activated and installed PyQt5. Did I do it right?
-
Yes you did, however PyQt5 is the package name, not its version. However since you just now installed it, it should be the latest version available.
Did you also uninstall the version you have installed system wide ?
-
I don't think I have installed PyQt5 system wide. Do you know how I can check if it is installed system wide?
-
@Mikenitin92 said in Error in my first Qt5 program:
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyQt5/QtWidgets.so
That path makes me think that it is since it's the OS provided Python framework.
-
-
A bit late to answer but I just found this, have a similar error, and might be of some help. Here is my error:
Traceback (most recent call last): File "bimpy/interface/bStackBrowser.py", line 6, in <module> from PyQt5 import QtGui, QtCore, QtWidgets ImportError: dlopen(/Users/cudmore/Sites/bImPy/bImPy_env/lib/python3.7/site-packages/PyQt5/QtGui.abi3.so, 2): Symbol not found: _futimens Referenced from: /Users/cudmore/Sites/bImPy/bImPy_env/lib/python3.7/site-packages/PyQt5/Qt/lib/QtCore.framework/Versions/5/QtCore (which was built for Mac OS X 10.13) Expected in: /usr/lib/libSystem.B.dylib in /Users/cudmore/Sites/bImPy/bImPy_env/lib/python3.7/site-packages/PyQt5/Qt/lib/QtCore.framework/Versions/5/QtCore
I am running on macOS Sierra (10.12.6) so the 'built for Mac OSX 10.13' part of the error makes sense...
I was able to get rid of this by downgrading PyQt from 5.14.1 to 5.13.0
Install a new virtual environment
# create a virtual environment in folder 'myenv' python3 -m venv myenv # activate the virtual environment source myenv/bin/activate
Check both pip and python are running rom it
which python # returns: /Users/cudmore/Sites/bImPy/myenv/bin/python which pip # returns: /Users/cudmore/Sites/bImPy/myenv/bin/pip
Install PyQt == 5.13.0
pip install PyQt==5.13.0 # I also needed PyQtChart==5.13.0 with pip install PyQtChart==5.13.0
Check the version of PyQt you install
pip freeze | grep PyQt
Gave me
PyQt5==5.13.0 PyQt5-sip==12.7.1 PyQtChart==5.13.0
Alternatively, if you want to downgrade to PyQt==5.13.0 in an existing install, simply do
pip install PyQt==5.13.0 --upgrade
If that doesn't work, first uninstall then reinstall
# just to be safe, first uninstall pip uninstall PyQt # then install specific version pip install PyQt==5.13.0
This build error is on the Qt dev end. I am needing to pay attention to this because me and my users are spread across macOS: 10.14, 10.15, 10.16, 10.17. I also have users on Windows 7/10 and this does not seem to be an issue?
Hope this helps...
Post 18 of 21