See here for more details. TylerGubala Makes sence that it is deprecated, since it was not available on all platforms to begin with. It was always spotty but I included it here, thank you for pointing this out. This is much cleaner than the other options. I would not recommend either of these two. The more reliable way is platform. See this answer: stackoverflow. Greg Hewgill Greg Hewgill k gold badges silver badges bronze badges. On the mac, os. On solaris, it's showing posix too.
Although your answer was fist and was correct, Greg Hewgill's answer was more complete, I appreciate your answer and advise you to, post more then just links, in the future. Yeah, it's the fastest gun in the west problem. I tend to post things quickly then edit with more info. Note: In some cases, this will return a screen full of information. If that happens, just scan through the file locations for the word python with a number after it.
That number is the version. Python2 and Python3 are different programs. Many programs upgrade from the older version to the newer one. However, Python 2.
Most systems differentiate Python 2 as python and Python 3 as python3. If you do not have Python 2, your system may use the python command in place of python3. Note : Python does not have a built-in upgrade system.
When writing an application, it is helpful to have the software check the version of Python before it runs to prevent crashes and incompatibilities. When this script runs, it will test to see if Python 3. If not, it will send a notification and displays the current Python version. So the winapi returns an incorrect version for you.
I'm looking for correct answers independently of the python interpreter target architecture. It's the OS architecture than I'm looking for.
Add a comment. Active Oldest Votes. I think the platform module is really the best way to get this info. Improve this answer. Curtis Price Curtis Price 2 2 silver badges 6 6 bronze badges. Luke Luke 3 3 bronze badges. Sounds good! Do you know if a user can alter these environment variables event unconsciously? WMI for os in c. ChristopheD ChristopheD k 27 27 gold badges silver badges bronze badges. Ok, added another option 2 - untested since I have no 64 bit windows OS around.
Thanks Christophe, this should work indeed! Connect and share knowledge within a single location that is structured and easy to search. Use sys. It works both on linux as well as windows. FYI: os. Platform is generic. For most usecases you should use the os. However if you need a more lean interface, try platinfo. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Can python detect which OS is it running under? Ask Question. Asked 10 years, 11 months ago.
0コメント