pythonpycharmhard-drive

Why does pySMART.smart import Smart not working?


Hi! I am on Windows 10. I'm writing a program, that can tell info about the parts of the pc it is running on. In Python.

I'm using the Pycharm IDE, the Community Edition 2024.2.1 (242.21829.153). I have Python 3.11.9 installed on my system.

At first, I wanted to install pySMART. I wrote 'import pysmart'. It told me, that I haven't installed it yet (doesn't remember the exact error message). I hovered over with the cursor, Install package; and Pycharm Installed it. Then, it was visible in the 'Python Packages' menu, but when I wanted to import it, it underlined it with red, and wrote: 'No module named pySMART'. I had to IDE repair. It refreshed the indexable files. My code ran.

Than; I deleted 'import pySMART', and wrote 'from pysmart.smart import Smart', because I wanted to type 'smart = Smart()' later in my code. Error message: "Unresolved reference 'pySMART'", and "Unresolved reference 'Smart'". Can't get over it. Tried IDE Repair again; nothing. Thried reopening project; nothing. Tried relaunching Pycharm; nothing. Thried logging out of Windows, then logging in; nothing. Tried restarting the computer; nothing. Please please please help me, I'm going crazy here.

Thank you in advance; The Humble Programmer.

I tried so hard, and got so far; but in the end, it doen't even mattered ;)

"Tried IDE Repair again; nothing. Thried reopening project; nothing. Tried relaunching Pycharm; nothing. Thried logging out of Windows, then logging in; nothing. Tried restarting the computer; nothing."

I were expecting Pycharm to delete this damn wavy red underline from the 'pySMART' and 'Smart' words, and to let me work in peace, but, to no avail.

I also tried relative import: 'from .smart import Smart', but this on not succeeded either. 'ImportError: attempted relative import with no known parent package'


Solution

  • fellow struggler. I feel your pain. I got it solved however.

    pySMART does not have a Smart() class. It has (as I recall) 4 classes, and neither of them are Smart(). [Device(), DeviceClass(), Attribute(), and TestEntry().] That's why 'from pySMART.smart import Smart' didn't worked. If you want to use it (I mean the pySMART package) properly, you have to first take the Device() class, and put it its returned value to a variable.

    storageDeviceList = DeviceList()

    Then, for all the storage devices it has found, you sorta question it withe the Device class, and it's attributes (In the for loop, you must put a '=' sign between the currently-monitored-device (variable) and the for-loop-declared-variable.). Somethink like that:

    for storageDevice in storageDeviceList.devices: currentlyMonitoredStorageDevice = storageDevice print(f"Manufacturer: {currentlyMonitoredStorageDevice.vendor}") print(f"Háttértár modellje: {currentlyMonitoredStorageDevice.model}") print(f"Háttértár sorozatszáma: {currentlyMonitoredStorageDevice.serial}")

    Ect., ect, ect.

    If you want to read pySMART's documentation, you can find it in this link. That can be a little tricky tho, so lemme show you around. You go to the Download button; next to it, you can find 2 options. Click on this: pySMART-1.3.0.tar.gz. (You'll need an installed WinRAR on your system.) Open ith with WinRAR, and go to pySMART-1.3.0/docs/pySMART.html. Once there, you can browse free in this ducumentation.

    Have fun, and I wish you a good time, coding. I know it can be hard, but hang in there Champ, you got it. Belive me.

    Oh, and bit of an advice, if I may... Don't trust ChatGPT or BlackBox AI blindly. These can mistake. These can fool you. These also can be a good start if you've got noooo indea, how to begin with, in the first place, but do your own research. Always. Don't waste precious days of your life on a false lead.

    Anyways, have a good one. Bye!