Attributeerror: Module 'os' Has No Attribute 'uname
When I do: >>> import os >>> os.uname() I get an attribute error which looks like this: Traceback (most recent call last): File '', line 1, in
Solution 1:
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.
Solution 2:
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')
Post a Comment for "Attributeerror: Module 'os' Has No Attribute 'uname"