LightBlog

dimanche 28 août 2022

How to install Python on Windows, Linux, and macOS

If you want to get into development, one of my favorite programming languages that I’ve learned is Python. It’s a multi-paradigm language, supporting imperative, functional, procedural, and object-oriented programming. It’s wide open and can be used for practically anything, and is a go-to language for many when working in artificial intelligence or machine learning. I use it for a lot of automation, and it’s even the language that some of the testing tools that we’ve used are written in.

Python is a powerful language, and if you want to get started with it, this guide will teach you the basics. Not only will you need to install the Python binaries and ensure that it’s in your PATH, but you’ll also need something to actually write code in. You could use a full-fledged IDE (Integrated Development Environment) like PyCharm, or you could lean towards a text editor such as the pre-installed IDLE or Sublime Text 3. There are a lot of options, but this guide should kick-start you on the basics.

Installing Python

On Windows and macOS

Installing Python is the easy part, and you’ll need to decide whether you’re installing Python 2.7 or Python 3.x. Python 2.7 is often used for legacy projects, but if you’re writing your own software, then you should install Python 3.x.

To install on Windows or Mac, do the following:

  • Go to the official Python site, and navigate to the most recent release. At the time of writing, that is 3.10.6.
  • Download the binary for your platform.
  • Execute the binary.

You don’t need to select any options aside from adding Python to your PATH, as the default installer has everything that you need. Simply clicking “Install” is all you need to do. On Mac, this will be done by default in the dmg installer.

python installer dialog

Installing Python on Linux

If you use Linux, though, then it will depend on the distribution that you’re using. Debian-based distributions (such as Ubuntu) can use the apt package installer in Terminal by executing the following command:

  • apt-get install python3.6

Other distributions may have it already pre-installed, and if not, you’ll need to use the package manager in your distribution. For example, on CentOS, you would execute “yum install -y python3”.

Verify Installation

You can verify your install is active, by running the “python” command in PowerShell, command prompt, or your Terminal.

python command run in command prompt


Choose your Python IDE

You’ll need an IDE or text editor to write code effectively, and there are a few options. Python comes with IDLE pre-installed, and while it works well, it’s not great for larger files that may be more complicated. Here are some of the IDEs that I’ve used for Python over the years, both in university and in my own projects. All of these IDEs are cross-platform, meaning you can run them on Windows, Linux, or macOS.

PyCharm

PyCharm IDE

If you’re familiar with Android Studio or IntelliJ, then you’re already familiar with PyCharm. It’s from the same developers, and you can even enable the exact same functionality in IntelliJ by installing the Python plugin. The difference is that PyCharm is built from the ground up purely just for Python, and packs all of the features you’d expect of any modern IDE. That includes built in version control, syntax highlighting, window splitting, debugging features, and more.

Download PyCharm

Spyder

Spyder IDE

If you’re a data scientist (or are going to be using Python for data science purposes), then you need to install Spyder. It’s an IDE that packs in some of the most popular data analysis packages for Python already. These include matplotlib, numpy, scipy, and pandas. If you want to get into data analysis, data plotting, and other scientific investigation, then Spyder is 100% what you need to install. Spyder even has Jupyter Notebooks built in, which can be used to explore and plot data really easily.

Download Spyder

Sublime Text 3

Sublime Text 3

Sublime Text 3 is one of my go-to text editors, simply thanks to its simplicity. It’s super versatile, though barebones, and more suited towards smaller projects. If you’re only working with a few hundred lines of code in a program that you’re writing, then Sublime Text 3 is probably the best way to go. I once wrote a web scraper in Python that would read local renting sites and email me and some friends a link to new listings just using Sublime Text 3 and Python. It’s a perfectly capable development environment and one that I think most people should be familiar with.

Download Sublime Text 3

Visual Studio Code (VSCode)

python visual studio code

Visual Studio Code (or VSCode) is one of the most versatile development environments out there. It’s entirely customizable, with a massive repository of plugins that you can access from within. It’s not compatible with Python straight away, but you can install a Python plugin from within that will enable syntax highlighting, intelligent code completion, Jupyter Notebooks, debugging, unit testing, and other features. I love Visual Studio Code, and it’s actually the IDE that I use the most when I’m working on something complex.

Download Visual Studio Code


What next

If you want to get started with development, there are loads of tutorials online that will teach you the basics. Between the likes of CodeAcademy and w3schools, there are lots of options. There are even Python interpreters on Android that you can use to write on your phone, and the best way to learn is by doing. If you’re doing anything resource-intensive that may use a lot of machine learning models or artificial intelligence, you might need one of the best laptops to handle it, though.

The best way that I learned was by realizing a problem or other difficulty I had and trying to figure out a way to automate the solution to it. That’s why I had the idea of writing a program that would scrape renting sites for me, and I’m sure there are other reasons you may find that you want to use Python, too.

The post How to install Python on Windows, Linux, and macOS appeared first on XDA.



from XDA https://ift.tt/8aU3O9o
via IFTTT

Aucun commentaire:

Enregistrer un commentaire