Python has a version 2 and version 3. What code do I use to ask Python what version I am using in the module
            Asked
            
        
        
            Active
            
        
            Viewed 100 times
        
    -1
            
            
        - 
                    2Does this answer your question? [How do I check what version of Python is running my script?](https://stackoverflow.com/questions/1093322/how-do-i-check-what-version-of-python-is-running-my-script) – hylowaker May 11 '20 at 05:37
- 
                    From the command line: `python --version`. From inside Python: `import sys` then `sys.version`. – Tom Karzes May 11 '20 at 05:39
- 
                    1In particular, if you only care about the major version, you can use `sys.version_info.major` – juanpa.arrivillaga May 11 '20 at 05:40
1 Answers
0
            
            
        Use sys.version_info:
import sys
print(sys.version_info)
The library is available for Python 3 and Python 2.
If you need to retrieve details about the OS, you can use platform
platform.python_version()
Returns the Python version as string 'major.minor.patchlevel'.
 
    
    
        olegsv
        
- 1,422
- 1
- 14
- 21
- 
                    1If you're printing it, just use `sys.version`, which is already formatted as a string. – Tom Karzes May 11 '20 at 05:46
