Which Code Editors Do Pythonists Use?

Originally published at: http://www.sitepoint.com/which-code-editors-do-pythonists-use/

Not into Python? Prefer Ruby instead? Here are the most popular editors and IDEs for Rubyists.

So, you’ve decided to learn Python? Great! Python is a really interesting programming language, that has been described as a descendent of ABC that appeals to Unix/C developers. And you can’t go wrong with a language named after Monty Python!

So yes, you have many exciting things waiting for you.

But one of the first things you’ll need to do is pick an editor you’ll use to write your Python program. Well, here comes the confusion. You’re faced with tons of editors out there, each with a community trying to get you attracted to using that editor. “Use vim!” “Use Emacs!” “Use Sublime Text!”

You recoil in fear… what if you make the wrong choice?

This feeling inspired me to interview Pythonists about their favorite Python editor. This will show which editors are used by the most Pythonists, and from there we can try to work out why. My hope is that it’ll serve as a guide for newcomers to Python, or even for those already working with Python.

I’ll start by discussing the most popular editors, then take a look at the advantages (and disadvantages) of the winner, before moving on to looking at how to install it onto your system.

The Survey

I spoke to 100 Pythonists, who brought up the following editors (presented here in order of popularity):

  1. Sublime Text
  2. Vim
  3. Emacs
  4. Notepad++
  5. TextWrangler
  6. IDLE
  7. Atom
  8. Aquamacs
  9. GNU Nano
  10. Kate
  11. gedit

Sublime Text was by far the most preferred editor, used by 45% of the interviewees. The charts below tell the tale:

From the figures above, we can see Sublime Text rules as the favorite Python editor from the sample I have interviewed. This seems to go hand in hand with Sublime Text’s slogan: The text editor you’ll fall in love with.

Sublime Text’s Advantages

So what makes Sublime Text so special?

Like others, I use Sublime for my Python work. I like the features mentioned in this post about Sublime Text. Briefly, these are:

  • Packages: Sublime Text comes with a fully-featured package manager that helps the programmer to discover, install, update, and remove packages for Sublime Text.

  • Macros: Instead of retyping simple strings of text, you can simply record macros and create a keyboard shortcut to output that text into your document.

  • Colors: In Sublime Text, you can quickly pick colors for the interface and text.

Other useful features for Sublime Text, as mentioned in this SitePoint Smackdown post, are as follows:

  • Comprehensive language support with TextMate-compatible grammar

  • “Goto Anything” quick navigation to locate files and code

  • A command palette to access all features

  • Extensive customization, great themes and numerous plugins

Sublime Text’s Shortcomings

However, Sublime Text still needs some improvements to become a better editor for Python.

Here are some ways Sublime Text could be improved to work better with Python:

  • In Sublime Text, some deep language specific integration features such as static analysis and refactoring, also available through plugins, are not that polished.

  • Dynamic analysis of code and autocomplete need to be enhanced.

  • Sublime Text could be made more friendly to new Python programmers. For example, if one needs to configure the application’s preferences, this is done by writing/editing lines of code. This is something a new programmer may feel uncomfortable attempting.

  • As a continuation to the previous point, Sublime Text needs to be simplified a bit, as it has a steep learning curve, and plugins need to be simplified, since they can be confusing.

  • While the app can be equipped with impressive features, these have to be installed separately, and some of them are not free.

  • Sublime Text is inaccessible via the terminal.

How to Set Up Sublime Text for Python

So, you want to give it a try? In this section, I’ll show you how to setup Sublime Text to work with Python. I will be demonstrating this on a Microsoft Windows 8.1 machine. If you want to do that on a MAC OS X machine, you can follow this tutorial, and on an Ubuntu machine, you can refer to this thread.

Let’s get started.

Installing Python

Download Python from here. I will download Python 3.4.2. This will be an msi file. Thus, the file you will get downloaded is python-3.4.2.msi. Run the installer, for which it will display the wizard shown in the figure below:

Navigate through the steps until you finish the setup wizard. You’ll notice that Python was installed in C:\Python34\, if you kept the default location.

Installing Cygwin

The next step is to setup Cygwin, a tool for providing Windows with similar functionality to a Linux distribution. If you’re on a 32-bit Windows, download the setup file from here. If you are on a 64-bit Windows, download the setup file from here. After you download the appropriate setup file, run that file, for which you will get the following start page in the wizard:

Keep navigating through the installer until you reach the following step:

In this step, we’ll be installing three software packages: curl, git, and openssh. For this, let’s use the Search box. For example, for curl, type the word in the search box, but, be careful, don’t hit the enter key, as this will continue the Cygwin installation. When you type curl in the search box, you should get something like the following:

What we want to do now is install each of the packages above. Click on the + sign. You will notice skip, click on skip, so you get the latest version number of the package, which we want to install. In this case, you should get something similar to the following:

Click the Next button, and wait until the packages are downloaded. This might take some time to finish.

Do the same for the other two packages, git and openssh.

After you finish, you should get a Cygwin shortcut at your desktop, like this:

cygwinIcon

Through this terminal, you’ll be running your Python code, in addition to accessing the packages installed above. If you double click the icon shortcut, you should get something like the below image:

To make sure that the packages were installed, and get an idea of their locations, we will use the
which command, as follows:

I was able to install Python through Cygwin using the following step (notice ‘Python’ at the end):

If you happen to miss this step, or you want Cygwin to find and use the Python version you installed above, you can issue this command in the terminal:

$ echo "PATH=\$PATH:/cygdrive/c/Python34" >> .bash_profile

Installing Sublime Text

Now, for the easiest part. To install Sublime Text, go to the Sublime Text homepage, download, and set it up. Very easy!

Test Your Installation

At this point of the tutorial, let’s test if our setup works, and we’re ready to use Sublime Text to work with Python.

Open Sublime Text, and type this line of code:

print("Hello Python!)

Choose File -> Save. In the Save As dialog box, choose where to save the file, name the file, and in Save as type:, choose Python. For instance, this is what I chose:

Now, open the terminal (Cygwin icon shortcut), and navigate to where you saved your Python file. In my case, it was on the Desktop. In my case, the file path would like like the following:

Finally, type the following command in the terminal to run the Python program:

python hello

In which case, you should get the following output:

You now have everything setup, and ready to delve through the Python world with Sublime Text! One of the first things you should do now is check out this collection of plugins for Python development with Sublime Text.

Conclusion

While Sublime Text has a commanding lead in numbers, that’s but one consideration. There are many popular editors, and it may not be right for every Pythonist. Nevertheless, it’s always good to know how the majority handle their projects, and there is something to be said for using a popular app or technology.

What is your favorite Python editor? How do you set it up for working productively?

Continue reading this article on SitePoint

Strange no one mentioned PyCharm from IntelliJ. I’m not that much of a Python developer, but when i did learn Python i used that IDE and it was everything i could wish for.

I must agree with @Eternal1 that it looks odd that PyCharm is not mentioned.

In my opinion, PyCharm is far superior as an IDE than Sublime Text. Though it is more expensive if you want the Professional version, but the extra features and the increased effectiveness you can work with easily justify the cost.

@Eternal1 @TheRedDevil Thanks for your comments. The article was actually targeted to editors and NOT IDEs. Yes, PyCharm is very popular, but, wasn’t mentioned here since it is considered an IDE. In order to see the difference between a text editor and an IDE, please check the first section of my post, here: http://www.sitepoint.com/ides-rubyists-use/

Please let me know should you have any questions.

Yes, you have a point here, but also it is worth mentioning that you can turn your Sublime Text into a full-featured IDE with plugins, and i guess most who use it actually do so. And it is true for other text editors as well (vim and emacs for sure).

@abderhasan Thanks for clarifying.

Personally I think the difference in the article is a little diluted, as with the plugins installed Sublime Text, vim etc, is no longer really a pure text editor. I really doubt the people that mentioned they use these actually use them bare boned.

So without taking with other IDE options, you are creating a false impression for new developers, making it look like they are not being used.

I also have friends who swear by iPython notebooks. I agree with the others that an article with “python” in the headline should look at what coding environments Pythonists use, rather than restricting oneself to an article about text editors, which may be better written to be language agnostic.

This is my point of view about Python IDEs. Moving from PyScripter to Pycharm.

http://www.manejandodatos.es/2015/3/changing-python-ide-pyscripter-pycharm

I think the title is misguiding, it should be “How Pythonists can use Sublime Text”.

It’s a lot of work, installation of packages and other software, to get a text editor to code python.

I know there’s a lot of love for Sublime Text, and it’s a very cabable editor, but it’s not the answer to everything.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.