-1

Python appears to be unable to locate the module QAxContainer in PyQt5. The package was installed using Conda and is present in a sub-directory of PyQt5 but cannot be located. Additional testing with pip resulted in the same error.

Ubuntu 20.04
Python 3.8.5

conda list
pyqt5 5.15.2 pypi_0 pypi

from PyQt5 import QAxContainer

ImportError: cannot import name 'QAxContainer' from 'PyQt5' (/home/brian/anaconda3/lib/python3.8/site-packages/PyQt5/init.py)

However, qaxcontainer.py is present in /home/brian/anaconda3/lib/python3.8/site-packages/PyQt5/uic/widget-plugins

user2514157
  • 545
  • 6
  • 24
  • There can be many reasons, which are mostly based on personal experience/perception, but generally it's because who downvoted thought that the question doesn't show enough research efforts, there was not enough documentation studying, there are typos or syntax errors, it's an unfocused (or too broad) question, what's being asked is unclear/unanswerable, asks about a problem while the real issue is elsewhere and is unspecified, it's poorly written or badly formatted, or it's a "I want to do x and don't know how, can you show me?" question. Or maybe just they wanted to downvote and that's it. – musicamante Jan 28 '21 at 02:33
  • Don't take it too personal (I know it can be considered like that, but usually it isn't). A down vote is just that, as much as a bad grade in school: it doesn't mean that your teacher has something against you. Not only you could (should) take it as a form of encouragement, but it isn't always up to the teacher to tell you "what was wrong", as an important part of the learning process lies in the self-awareness and being able to understand your errors on your own (as much as we shouldn't tell you that asking about an outdated/unsupported framework is pointless if your problem is elsewhere). – musicamante Jan 28 '21 at 02:41
  • I appreciate the insight. – user2514157 Jan 28 '21 at 02:46

2 Answers2

2

There should be QAxContainer.pyd and QAxContainer.pyi at /home/brian/anaconda3/lib/python3.8/site-packages/PyQt5/. If you dont have them maybe there's a problem with the package, try reinstalling PyQt5.

abadillo
  • 195
  • 1
  • 5
  • 1
    Your reference to .pyi Windows specific file extension lead me to my answer below, i.e., QAxContainer is not being installed because it is Windows specific and I am running on Ubuntu. – user2514157 Jan 27 '21 at 23:17
1

According to antonio2924, QAxContainer.pyd and QAxContainer.pyi should be located at /home/brian/anaconda3/lib/python3.8/site-packages/PyQt5/. The .pyd file extension is specific to Windows. Furthermore:

The QAxContainer module is a Windows-only extension for accessing ActiveX controls and COM objects. See, https://doc.qt.io/qt-5/qaxcontainer-module.html

I am running Ubuntu 20.04, which explains why QAxContainer is not being installed.

user2514157
  • 545
  • 6
  • 24
  • While ActiveX is technically not dependent on Windows, practically has only be used on that platform. And, I have to say, it's a well-known framework (as it's well known that it's aimed for Windows only) as it is *old* and considered deprecated. Why are you [still] using it? – musicamante Jan 28 '21 at 01:28
  • I am new to PyQt and having a heck of a time trying to create a GUI that includes a PDF viewer. I was trying to run the example at: https://stackoverflow.com/questions/23389001/how-to-render-pdf-using-pdf-js-viewer-in-pyqt. I cannot seem to find a working example that supports Qt with python bindings on Linux, either as directly as a PDF widget or rendered within a web browser widget. – user2514157 Jan 28 '21 at 02:06
  • PDF displaying is not immediate in PyQt, and if you're a beginner it might be hard to achieve. That said, your issue is a clear example of an [XY problem](https://meta.stackexchange.com/q/66377): if you can't show a PDF in PyQt, the you should ask about *that* (or, at least, specify it in your question), not about unrelated subjects. If you need to buy a car, and you've seen one that is sold at 500$ per month in 10 years, you don't ask people how to earn 500$ per month for the next 10 years. Start from the example you linked, if you don't get it working create a question *about that*. – musicamante Jan 28 '21 at 02:19