21st Sep 2022 9 minutes read 4 Best Python IDE and Code Editors Luke Hande python IDE If you want to learn to program in Python, you’ll need a code editor or an IDE. Find out which ones we recommend in this article! Professional software developers spend their whole day at the computer, writing and testing code. To make their programming lives easier, many Integrated Development Environments (IDEs) have been developed to help make programming more efficient. An IDE is simply a program in which you can write and run your code. Each IDE comes with its own set of features. These could be things like syntax highlighting, debugging functionality, a nice way to view all the files in your project, and version control. In this article, we’ll show you the best IDE and code editors for Python. For each one, we’ll explain their best features as well as their weaknesses. If you’re new to Python, our Python Basics track makes a good starting point. It combines three of the most useful courses for complete IT beginners. If you already know you’re going to use Python to work with data, our Python for Data Science track would also be a great choice. But Before We Get Started... Before we begin discussing the best Python IDE and code editors, it’s worth explaining the most basic way of creating and running a Python script. To create a script, just open any text editor, such as WordPad. This is a very bare-bones text editor that has been around for decades. You can simply start writing Python code – for example, a for loop that prints out the numbers in the loop. Then save the file as script.py and you have your Python script! To run your script, open the terminal (i.e. the command prompt or command line), navigate to where your script is, and simply run: >>> python script.py This will then print the contents of the loop to the terminal. It is possible to develop whole projects in this way, but it’s not easy. Basic text editors don’t come with features to help you write and test code. It’s kind of like trying to dig a hole with a plastic spoon – you can do it, but there are better ways. So, let’s take a look at some of the best Python IDEs to make your programming easier. Our Top 4 Python IDEs and Editors Spyder The first IDE on the list is Spyder. This development environment strikes a good balance between ease-of-use and helpful features. And best of all, it’s free! It is mainly aimed at scientific programming and comes with a highly customisable interface. The file explorer allows you to browse, open, and manage files and folders in your project. For projects with many directories and files, it provides a nice overview of the structure of the project. Next is the editor, where you write your Python code. Here, you can have multiple scripts open and easily switch between them. The editor comes with customizable syntax highlighting; as you write your code, the editor shows you all possible arguments which can be used. If you happen to make an error (e.g. a typo), the editor will catch it before you even run your script. Executing the script is done with a mouse click; the output will be visible in the console. Using the console, you can interact with your program to print the variables and explore your data. You can also use the console to develop and test code for a new function, which you then copy over into the script in the editor. Spyder also supports debugging, has a variable explorer, and a history of previous commands. You’ll find a lot of these features in other Python IDEs. Spyder lacks some more advanced features like version control, but its usability makes it a great choice for many projects. Jupyter Notebooks The next IDE is a free popular tool for developing data science projects. Writing Python code in Jupyter Notebooks takes place in the web browser, and the scripts themselves (which have the .ipynb extension) are known as notebooks. Each notebook consists of cells where you write your code; each cell can be executed separately, with the output shown directly below it. If you want to visualise some data, the editor will also display plots. The progress of your code execution is saved, so you don’t have to remember which cells have already been executed. The editor comes with syntax highlighting and autocomplete (which automatically closes brackets and quotation marks). You can run the whole notebook with a single click and go back to add cells above or below the current cell. Developing code in Jupyter Notebooks is useful if you want to build a quick prototype or do some exploratory data analysis. It’s also useful to showcase your work to others. You can step your friends through your analysis cell by cell and see the results immediately. This is a great way to help others understand how the code works. However, this IDE does have some weaknesses. The cell-by-cell nature of programming in Jupyter Notebooks can get in the way of developing in a more object-oriented way, which is necessary for larger projects. Furthermore, if you’re not thinking in terms of functions and classes, you tend to duplicate a lot of code, which is error prone and difficult to maintain. As we mentioned above, the notebooks have their own file extension. If you want to create a Python project with .py files, you’ll need to work in another IDE. Visual Studio Code Visual Studio Code (VS Code) is a free and open-source IDE that can be used to develop software in several languages, including Python. This is one of VS Code’s main advantages: if you need to develop applications in different languages, you only need one IDE. This IDE shares a lot of the functionality you’d expect in a mature development environment: syntax highlighting, customisable themes, easy access to a functions docstring, and a large community of users. If you’re starting from a fresh install of VS Code, you’ll need to install some extensions to allow you to code in Python and give you access to additional functionality. There are many options to choose from. For example, you might want type checking to make sure you’re not putting a string where an integer belongs. Code formatting can be useful to tidy up your import statements by combining multiple imports into one line. And while an autocomplete feature is available, it can be a little wacky. Remember how Jupyter Notebooks requires a second IDE to work with .py files? Well, VS Code has a Jupyter extension; you can work on your Jupyter Notebooks in VS Code. That’s a nice feature if you want to polish your prototype and develop it into an app. VS Code comes with some more advanced features to help you manage virtual environments and version control, including an extension to give you access to the GitHub Copilot. This is an Artificial Intelligence tool that can automatically suggest whole blocks of code, which can be a real time saver. PyCharm PyCharm is an IDE developed by JetBrains, a Czech software company with a range of products that include IDEs designed for other languages. PyCharm forms a part of this larger ecosystem and their products play nicely together, so this could be a compelling option if you’re a coding polyglot working in multiple languages. Unlike VS Code, PyCharm was developed specifically for and natively supports Python. After installing the IDE, you can jump straight in and take advantage of its large number of features. This IDE was created with the needs of professional software developers in mind, so it’s more suitable for larger projects, possibly involving multiple people developing the same project. Like some of the other IDEs we’ve discussed so far, PyCharm is customisable to suit your preferences and comes with many standard features. It also has in-built support for managing virtual environments. This makes it very easy to create a new virtual environment, install all the necessary libraries for each project, and keep the environments isolated to avoid any annoying conflicts between different packages. If you’re part of a team of developers, project managing using version control software (like Git) is very important. Happily for PyCharm users, this functionality is built into the IDE. All you need to do is create a repository and define its location; then you can do things like push and pull all from within the PyCharm IDE. This IDE has a few drawbacks. Firstly, you’ll need to pay for the pro version. There is a community version free of charge, but it lacks some features. Furthermore, PyCharm was not built with data science in mind, so exploring your data is not as easy and intuitive as it is with Spyder. An Honorable Mention: The Vim Text Editor To round out the discussion on IDEs, it’s worth mentioning the legendary Vim. Vim is a powerful command-based text editor, which means it allows you to work without needing to use the mouse to click menus or navigate around. When you open Vim, you’ll find yourself in command mode. If you want to write some code, you need to enter insert mode by typing i. Once you’ve written some Python code, hit escape to return to command mode. You can save and quit Vim by typing: wq (w for write, q for quit). Then you’ll need to run your program from the terminal, like we showed at the start. We have an article on How to Open and Run Python Files in the Terminal with more information. Vim has a steep learning curve; as a beginner it can be tricky and unintuitive to do very simple things such as navigating around and copying and pasting text. But once you master the most important commands, using Vim can be very fun and efficient. Learning Vim is useful if you ever need to execute some code or configure files on a remote server, since there might not be any other IDEs or editors available. Pick Your Python IDE There are many more IDEs out there, each with their own strengths and weaknesses. In this article, we showed you some of the best IDEs for Python. You should now have enough background to start exploring which one suits your needs best. If you’re wondering what kind of programmer you could become, take a look at the article Should I Learn Python? Is Programming the Right Career for Me?. Python is a great tool which could help land you a rewarding Python Job and Salary in 2022. But for those of you who are masters at procrastination, the least you could do is check out some Movies That Will Inspire You to Learn Python. Happy coding... or viewing. Tags: python IDE