When I do:
>>> import os
>>> os.uname()
I get an attribute error which looks like this:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
os.uname()
AttributeError: module 'os' has no attribute 'uname'
How can I fix this is my python broken or something else because in the docs. Thank you in advanced.
I've run your code the exact same way in IDLE on Windows 10 and got the same result.
>>> print(os.uname())
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
print(os.uname())
AttributeError: module 'os' has no attribute 'uname'
And as @Joran Beasley pointed out, this function is only available in certain operating systems.
From an online compiler:
posix.uname_result(sysname='Linux', nodename='Check', release='5.4.10-x86_64-linode132', version='#1 SMP PREEMPT Thu Jan 9 21:17:12 UTC 2020', machine='x86_64')
If you want to get current os, I recommend the platform
module.
>>> import platform
>>> platform.platform()
'Windows-10-10.0.18362-SP0'
Some people prefer using os
module, but platform
is much more readable.
Unfortunately, the uname
function only works on some Unix systems. If you are on Windows, you can use the uname
function in the platform module, which returns a similar result.
>>> import platform
>>> print(platform.uname())
uname_result(system='Windows', node='DESKTOP-OVU16P3', release='10', version='10.0.19042', machine='AMD64')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With