Are more startups choosing Python instead of Ruby


With the entry-level and user-friendly programming language Python, you can code almost any imaginable application. But it's just a piece of software like any other - installation and management can sometimes be complex.

We'll tell you how to set up Python, determine the right version for your purposes and avoid possible pitfalls when installing on Windows, Linux and MacOS.

Determine the correct version of Python

About compatibility With third-party modules, you should not use the latest Python version. Instead, the last major versioning is recommended. Currently (as of February 2021), Python 3.9.2 is the latest version. So to make sure everything works, you should opt for the latest revision of Python 3.8. Of course, you can test the latest Python version at any time in a protected environment such as a virtual machine.

There are also various distributions of Python - very similar to that on Linux the case is. However, the programming language is, in contrast to Linux, also available in an official version that you can use as a fallback option: CPython is made by the Python Software Foundation made available and is the safest and most compatible distribution. You can always experiment with other Python distributions for specific use cases at a later point in time.

An essential point when choosing the Python distribution - especially under Windows - is the decision between the 32-bit and the 64-bit version. You will most likely choose the latter because:

  • most modern operating systems work with the 64-bit version of Python by default. Windows users can use the 32-bit versions of the Coding language also operate with a 64-bit Windows, but have to be prepared for slight performance losses.

  • 32-bit applications - including Python - can access a maximum of 4 GB of RAM at the same time. 64-bit apps don't know this limit. In addition, there are many Data analysis and machine learning tools run best in a 64-bit environment.

You should only opt for the 32-bit version of Python if you also have a 32-bit version of Python.Windows or (must) use a third-party module, which is only available as a 32-bit version.

Install Python on Windows

As with almost every application under Windows Python is installed using an installer that guides you through the setup process. By default, the Python installer saves .exe files under Windows in the app data directory of the respective user - so that no administrator rights are required for the installation.

Find the right Python installer for Windows represents several different Windows Installer available. In addition to the 32-bit (x86) and 64-bit version (x86-64), there is also an embeddable zip file, an .exe file and a web-based installer. These differ as follows:

  • The .exe installer is just an executable file that starts the Python installation process - this is the most common and simplest solution.

  • The web-based installer is basically identical to its .exe counterpart, with the difference that it downloads the files necessary for the installation separately. This drastically reduces the size of the installer, but a network connection is essential.

  • The embeddable zip file is a self-contained, minimally reduced copy of the Python runtime environment. This is useful if you want to distribute a Python application manually or if you want to test something quickly. However, this installer does not contain any of the useful tools that the other versions have on board.

Install Python with a package manager on Windows

Another option under Windows is the use of the operating system's own package management system NuGet. The Package Manager for .NET also has Python on sale, but as a component for .NET applications and not to be used as an installer for a standalone version of Python. The management of your Python instance should therefore be easier with a regular installation.

That too Windows Package Management System Chocolatey provides Python. This is usually a better option than NuGet because it checks your system for an existing Python runtime environment. However, you should avoid mixing regular installations and those with Chocolatey on one system.

Install Python on Linux

Because Linux-Distributions sometimes have significant differences, you should install Python under the Open sourceOperating system can also use the package manager of the respective distribution. For example, the installation procedure differs in the case of Ubuntu and Fedora fundamental. The installation target directory is usually based on the Python version number (/usr/bin/python3.x).

One way of dealing with the complexity LinuxPackage managers can be avoided by using a container-based Python runtime environment. Container are isolated from the rest of the system - so you don't have to worry about different Python runtimes causing conflicts. If you are not experienced in handling containers, however, you will need to allow a little time and effort to to get acquainted with the matter.

The tool asdf-vm is helpful to run multiple Python runtimes on Unix based systems (Linux and MacOS). The tool is not limited to Python: several runtime environments for Node.js, Ruby, Elixir and many other programming languages ​​can be brought under one roof with asdf-vm.

Install Python on MacOS

Apple's MacOS was shipped with a pre-installed Python version for a long time - but no version newer than 2.7 was used. With the release of Python 3.0, this often led to problems or conflicts. The official Python documentation goes into this problem in passing, but only offers the recommendation as a solution to choose the correct path for the corresponding Python instance.

The use of the Homebrew Package Managers is a common way to manage Python runtimes on MacOS. This provides a consistent interface for downloading, (de-) installing and managing Python.

Install Python packages

When you have completed the basic installation of Python, you should not install the packages directly with Pip (the Python Package Manager) in the next step - even if you only want to use Python for a single project. Instead, it is advisable to set up virtual Python environments and install the packages within these environments. This way the basic installation remains "clean".

Managing a large number of projects with virtual environments can be challenging. Here is a good look at that Command line tool Poetry.

Install several Python versions in parallel

It gets really tricky when there are several different versions of the programming language should be installed in parallel. Here you should pay particular attention to two things:

  • Always install each Python version in its own directory.

  • Make sure that the system paths first point to the version of Python that will be used by default.

Setting up virtual environments for each individual project is highly recommended if different Python versions are to be used in parallel: This ensures that the correct version of the coding language is always used automatically when the corresponding virtual environment is activated. Windows- In this context, users have another option with the Py Launcher app. This can be added as part of the installation process and enables you to use command line flags to select which Python version should be used for the respective script.

Upgrade Python properly

Less extensive Python revisions (e.g. from 3.7.2 to 3.7.3) are usually not a problem: Under Windows the installer automatically detects the installed version and triggers the appropriate upgrade - under Linux and MacOS usually as well. However, any virtual environments that you have created must also be upgraded - this does not happen automatically.

With large revisions (e.g. from 3.7 to 3.8), however, you should create new virtual environments within the individual project directories. Most IDEs that support Python (for example Microsoft Visual Studio Code) recognize this automatically and allow you to switch back and forth between the various virtual environments.

This article is based on an article from our US sister publication InfoWorld.