Cookies disclaimer

I agree Our site saves small pieces of text information (cookies) on your device in order to deliver better content and for statistical purposes. You can disable the usage of cookies by changing the settings of your browser. By browsing our website without changing the browser settings you grant us permission to store that information on your device.

Python, Django and More

Python 2 or 3? 32 or 64 bit? Which one to choose?

In this article, I will explain what are the differences between 32 bit and 64 bit python and which python version you should use.

This is a beginner topic, so if you are an advanced user, this won't say any news.

Python 2 or 3?

This section will be really short. Use python 3, because the python 2 support will be shut down to end of 2019. If you are a beginner, you don't need to hesitate.

Python 2 used in legacy codes in companies only, where it has not value for money to refactor all the code.

If you have to use both python, stay tuned, I will make an article about using simultaneous both version without problems.

32 or 64-bit?

The system itself built with 32 or 64 bit processor. It tells how much RAM the system could use. The 32-bit processor can reach 4 GB of RAM (2^32), even if you put more to your PC. The 64-bit processor can reach 18-Quintillion GB of RAM (2^64), which more than enough. The first case, you can only use 32 bit programs. The second case, you can use both 32 and 64 bit programs.

If you are aware which version you should use, use 32 bit. But in this case, you have to you 32 bit version of all package you will try to install. If you can install the package via pip, it will solve for you, but sometimes the pip couldn't (mainly on windows, for example build error) and then you need to choose the correct one. It will raise error if you have chosen wrong one anyway.

Note: I will link a corresponding post about installing packages and using whl files too, when I am done with writing.

To check which version you have installed or which version pre-installed on your system (on unix), just type python in your console. The first few lines tell you.

It seems something like this:

$ python
 Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32
 Type "help", "copyright", "credits" or "license" for more information.

Which means 64 bit of python.

On unix like system, you can check different way (works on windows as well):

$ python -c 'import struct;print( 8 * struct.calcsize("P"))'
$ 64 # or 32 based on python version
Note: If you got command not found error, you need to check if it installed.
On mac: the apple won't pre-install python from a specific version. Maybe you need to install by hand.
On Windows: Windows doesn't pre-install python. If you have installed correctly, and got not found error, then you need to check if the PATH system envorinment variable contain the path, which contains the python.exe. I will write about environment variables in another post, stay tuned, I will link here :)
On Linux: Always pre-installed, but sometimes only python 2. If you got this error, you can check the PATH variable too. There will be another post about installing and building python in case if that needed.

Let's get back to the topic.

To check whether your system 32 or 64 using command line:

# UNIX (Mac or Linux):
echo "You are on a "$(getconf LONG_BIT)"-bit architecture"

# Windows:

There are times when you need 32-bit of Python, even if you have 64-bit OS. Some package may require that. It is so rare, I haven't had to use 32 and 64-bit Python on the same system (possible but uncomfortable). I can write about it if you are interested in that.

I hope you got a vision of what these all about.

Thanks for reading my post. If you would like to see more check my other posts and subscribe to my email newsletter for more: Subscribe here

You can support this site via Patreon or sharing this post.

In case of further question or suggestion write me in the comments below or check my Forum for corresponding topics

blog comments powered by Disqus