2021年5月5日星期三

Get PyCharm to acknowledge PyQt4 package (Ubuntu)

I have moved from Windows, where my PyQt4 development was working, to Linux where it is not. I went through the process to download each tool, including python2.7 and PyQt4 from https://www.riverbankcomputing.com/static/Downloads/PyQt4/4.12.3/.

Now that I try to run it in PyCharm, I am seeing that QtCore and QtGui are not found. I have seen a good handful of posts regarding fixes for similar issues, but I haven't been able to find a solution for my case yet.

  • I have installed everything under Python2.7 (and did not have Python3 until after, when I tried a workaround).
  • My interpreter in PyCharm is listed as Python 2.7.
  • I do NOT see PyQt4 listed in my packages. I cannot add it from within PyCharm because it uses "pip install PyQt4" which gives the following error in PyCharm:

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality. ERROR: Could not find a version that satisfies the requirement PyQt4 (from versions: none) ERROR: No matching distribution found for PyQt4

  • I set up a new venv and noticed that the PyQt4 stuff was not inside. So I copied everything from my usr/lib/python2.7/dist-packages location. I also saw that I had other files in usr/share/sip, so I added those too as it still did not fix the issue.
  • I have also tried suppressing the warnings as another Stack Overflow post mentions, but it has issues finding imports from within QtGui/QtCore (such as Sip).

I'm unsure of what else to check for and would appreciate any help. Should I set up my VENV elsewhere, or copy more stuff into it?

I don't know if this is helpful, but my process for installing PyQt4:

>wget https://www.riverbankcomputing.com/static/Downloads/PyQt4/4.12.3/PyQt4_gpl_x11-4.12.3.tar.gz  > tar -zxvf PyQt4_gpl_x11-4.12.3.tar.gz  > cd PyQt4_gpl_x11-4.12.3  > python2 configure.py  > make  > sudo make install  > cd ..  > rm -rf PyQt4*  

My process for installing sip (which was done before installing PyQt4):

> wget https://www.riverbankcomputing.com/static/Downloads/sip/4.19.24/sip-4.19.24.tar.gz  > tar -zxvf sip-4.19.24.tar.gz  > cd sip-4.19.24  > python2 configure.py  > make  > sudo make install  > cd ..  > rm -rf sip*  

After installing Python3, I tried installing PyQt4 via python3, but had the same issue. It did not show up in the package list, but I did not check any VENV settings with it and have since moved to another VENV. If it is worthwhile, I can go down this avenue more.
I have also installed PyQt5 and can confirm shows up in my package list (with the Python3.8 interpreter). I am looking to avoid converting to QT5 yet, as I would like to finish my current task before spending the "extra time updating everything."

If there is anything I left out, or if there's any more information that would be helpful, please let me know!

https://stackoverflow.com/questions/67410931/get-pycharm-to-acknowledge-pyqt4-package-ubuntu May 06, 2021 at 10:08AM

没有评论:

发表评论