Install Python?

Python is simple to use, a breeze for beginners, and powerful enough to make software for almost every application. However, it’s an application like others, and it cannot be easy to set up and manage.

In this article, we’ll go through the steps to set up Python correctly by determining the correct version, the best way to prevent different versions from crossing one another, and how to stay clear of all the other sharp corners and errors in the process.

Choose the correct Python Version and Distribution.

To ensure compatibility with third-party modules, it is best to use a Python version which is one point revision in advance of the latest version.

At the time of writing it is at the time of writing, Python 3.8.1 remains the most up-to-date version. The most secure option using the latest Version is Python 3.7 (in the present instance, Python 3.7.6). You can try the latest versions of Python in a controlled manner- e.g., in a VM or testing machine- but reverting back to a previous version will ensure the highest compatibility with popular third-party Python software.

Python is also available with a range of distributions, much like Linux. However, unlike Linux, Python offers one gold-standard “official” version that you can always depend on CPython, the version offered through the Python Software Foundation at Python. This is, in fact, the most secure and compatible one, and one that isn’t fired for choosing. (You may want to look into different Python distributions in the future, as they can address specific needs that you may have; however, we will not consider them in this article.)

The most important decision you’ll have to make, particularly when using Windows, is choosing the 32-bit or 64-bit Version of Python. The most likely choice is 64-bit due to several reasons.

  • Modern operating systems typically use 64-bit versions of Python by default. Windows users can use 32-bit versions of Python on 64-bit Windows but with a small loss in performance.
  • 32-bit Python, as well as 32-bit applications generally, can access just the memory of 4GB at a time. 64-bit programs do not have this limitation, and, as a result, many machine learning and data analysis tools that use Python can be used with 64-bit versions. Certain are only available with the 64-bit version.

The only reason you need to select the 32-bit Version of Python is when you’re using an older version of 32-bit Windows or you have to utilize a third-party application that is only available with a 32-bit edition.

Set up Python on Windows with the right method

Python runs on Windows like any other program via an installer that walks users through the installation process.

By default, the Python installation for Windows puts its executables into your user’s Application Data directory, which means it does not require administrator permissions. If you’re the sole person using the computer, you may consider placing Python within a more advanced directory (e.g., C:\Python3.7) to facilitate finding. The Windows installer allows you to select the directory you want to target.

Select the correct Python installation for Windows

Python offers a range of various versions of Python that run on Windows. Apart from 64-bit (“x86”) and 32-bit (“x86”), and 64-bit (“x86-64”) versions previously listed, you can select from the embeddable zip files and the executable installer as well as the online installer. Let’s see what they’re about:

  • It is an executable installer. The executable installer is the. EXE file that performs the setup procedure for Python. This is the most straightforward choice and also the most frequently employed.
  • This internet-based version is similar to the executable installer, except it separately downloads the required components for the installation. This drastically decreases the size and weight of the installer. However, it still requires an internet connection.
  • This Zip file can be embedded in a self-contained small copy of Python runtime, which fits into one folder without dependencies. It’s a good idea to include it if you wish to make available a Python application by hand or when you require just a single, quick Python installation to test an application on the spot. The embeddable zip doesn’t contain pip or any other useful tools included with the full installation, so it’s intended only for experts.

Install Python by using a package manager on Windows

Another option is to use one of the package management software systems available for Windows, such as NuGet, the manager for packages used in .NET, which offers Python in its repository. However, Python can only be downloaded as a component within a .NET application and not as a standalone software development tool. Installing Python in the conventional manner is more straightforward and convenient for managing your Python instance.

Chocolatey is a more general Windows package management software that includes Python. Chocolatey offers a simple method to execute its Python installer and monitor whether you have it. It also tracks the presence of Python language runtime on your system. It’s it is a superior choice to NuGet. However, avoiding Chocolatey installations and regular installs that use Python on the same computer is best.

Set up Python for Linux, the method that is the most efficient

Since Linux distributions vary greatly, The most common method to set up Python in Linux is using the appropriate package manager for the distro. Ubuntu and Fedora, for instance, use completely different methods for installing Python. On Linux (and MacOS), the target directory for the install is usually predetermined and based on the Python version number, e.g., /usr/bin/python3.X on Linux, or /usr/local/opt/python/ on the Mac.

One method to not have to deal with the complexity that comes with Linux program managers is to utilize containers for your Python runtime. Containers operate in isolation from the rest of the system, so you do not have to be concerned about various Python runtimes getting onto each other’s feet. If your workflow still needs containers, you’ll need to dedicate time and energy to becoming familiar with Docker. (Note that you can use containers for Python on Windows too.)

A tool called asdf-vm can also be useful in this case. It can help you manage several Python runtimes for Unix-like systems (Linux and MacOS) and multiple runtimes that support Node.js, Ruby, Elixir, and many other languages. So, if you have to manage other languages apart from Python, it is recommended to investigate asdf-vm.

Installation of Python onto MacOS the right method

MacOS typically comes with the latest version of Python installed; however, it has never been any later than Python 2.7. This caused difficulties with the time Python 3 arrived, as the two versions frequently conflicted. The official Python documentation includes some suggestions on this issue; however, it only offers specific recommendations to ensure that you choose the correct route for the Python instance you’re interested in.

The most common method of managing Python runs on MacOS is via Homebrew. Homebrew package manager. Homebrew is a standardized interface for installing, downloading, and managing Python and other third-party command-line applications.

Install Python packages in a smart and efficient way

After you have a basic installation of the Python version, wait to start installing packages directly in it using pip — not even if you intend to use Python for just one project. Create your project’s directory, install Python virtual environments in the directories, then install Python-related packages into these virtual environments. So, the base installation is kept clear.

If you are looking for a way to manage several projects with a dependent and virtual environment, consider Poetry. Poetry program. Poetry is a command-line program to manage virtual environments and dependencies on a higher level.

Install several Python versions side-by-side

The biggest challenge in working with Python installation is managing various versions of Python running side-by-side. Two general rules of thumb apply:

  • Always install every version in a different folder.
  • Make sure that all path on your system is configured so that they point first at the specific version you’d like to use by default.

Multiple Python versions are strongly for using virtual environments for each project. If the virtual environment is activated, every Python activity in the project’s context is automatically redirected to the correct version of Python,

Another alternative Windows users have to choose the Python version to choose in the event of multiple versions being installed is to use the Python launcher application. In Python installation, you’re given the option to install the Python launcher, a tiny executable that allows you to choose (via command-line options) the Version of Python to run any given script. For example, to run pip for Python 3.7, it would enter pip -3.7 pip -m.

Make the most of Python, the smart method.

Minor revision updates for Python — e.g., Python 3.7.2 to Python 3.7.3 are generally straightforward. On Windows, the installer will detect the current version’s existence and then upgrade it. In Linux and MacOS, the installer or package manager usually does the same.

But, all virtual environments that you’ve created also require upgrading. They do not upgrade automatically. If you want to upgrade Python in a virtual environment, navigate to the virtual directory and then type the command upgrade. Note that this is most effective for minor revisions to point numbers, such as Python 3.7.2 up to Python 3.7.3.

Suppose you’re planning to perform major revisions to your point of view, for instance, the upgrade from Python 3.7 or Python 3.8. In that case, the best option is to utilize Venv to make a brand new distinct virtual environment subdirectory within the project directory, reinstall all dependencies, and switch to this new virtual world. Most IDEs have Python support for Python (e.g., Microsoft Visual Studio Code), which can detect several virtual environments within your project, and let you switch between the different environments.