How To Check If Python Is 32 Or 64-bit Windows

When you run a python program on Windows, you may want to know whether the Python version is 32-bit to 64-bit, because some issues may happen when you run the python program with the wrong python bit version. This article will tell you how to check whether you python is 32-bit or 64 bit after you install it.

1. How To Check If Python Is 32 Or 64-bit Windows.

There are 2 methods to check if python is 32 or 64-bit version on windows.

1.1 Method 1.

  1. Input the keyword cmd in the Windows OS Type here to search text box.
  2. Press Enter key to open a Dos window.
  3. Input the command python in the dos command line, press Enter key to run it.
  4. Then it will display some Python-related information. From the first text line, we can see the python is the 32-bit version ( MSC v.1915 32 bit (Intel) ).
    Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
  5. If the python is a 64-bit version, then it will display the below text ( MSC v.1916 64 bit (AMD64) ) when you run the python command.
    Python 3.8.3 (default, Jul  2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
    Type "help", "copyright", "credits" or "license" for more information.

1.2 Method 2.

  1. You can also run the below python script to check if python is 32 or  64-bit version.
    # First import struct module.
    >>> import struct 
    # Return 64 means 64-bit version, return 32 means 32-bit version.
    >>> version = struct.calcsize("P")*8 
    >>> print(version)

2 thoughts on “How To Check If Python Is 32 Or 64-bit Windows”

  1. In the above demo of 64 bit python, why does it show as “on win32”?

    more specifically, my 64 bit python installation on a 64 bit windows instance also shows this. Surely this reference to win32 shouldn’t be there.

    1. The term “win32” in this context does not specifically refer to the architecture of the operating system but rather to the historical context of the Windows API. The term “win32” is often used to refer to the programming interface for the Microsoft Windows operating system, and it has been maintained for compatibility reasons even in 64-bit versions of Windows.

      Even though you have a 64-bit version of Python installed on a 64-bit Windows instance, the reference to “win32” is used to indicate that the Python installation is utilizing the Windows API, which includes support for both 32-bit and 64-bit architectures. This allows Python to maintain compatibility with various Windows applications and libraries that rely on the “win32” API.

      Therefore, seeing “win32” in the Python environment on a 64-bit Windows system is not indicative of any issue with your installation. It is simply a historical reference that Python uses to maintain compatibility with the Windows API across different versions of the operating system.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.