Mod1: import platform | Python Language Forum
G
Gaurav Valera Posted on 08/05/2021

Hi,

Please guide me to resolve following:

Code:

import platform
print(platform.python_version())

Output:

Traceback (most recent call last):
  File "C:\Git_Data\automationFrameworks\PythonMay\mod_1\platform.py", line 1, in <module>
    import platform
  File "C:\Git_Data\automationFrameworks\PythonMay\mod_1\platform.py", line 2, in <module>
    print(platform.python_version())
AttributeError: partially initialized module 'platform' has no attribute 'python_version' (most likely due to a circular import)

Y
Yogesh Chawla Replied on 10/05/2021

You can also use this code to print platform information:

 

import sys
import os

def main():
    v = sys.version_info 
    print(v)
    v = sys.platform
    print('Python Version - {}.{}.{}'.format(*v))
    v = os.name
    print(v)
    v = os.getenv('PATH')
    print(v)
    v = os.getcwd()
    print(v)
    v = os.urandom(25).hex()
    print(v)
    

if __name__ == '__main__' : main()