186

In RStudio, you can run parts of code in the code editing window, and the results appear in the console.

You can also do cool stuff like selecting whether you want everything up to the cursor to run, or everything after the cursor, or just the part that you selected, and so on. And there are hot keys for all that stuff.

It's like a step above the interactive shell in Python -- there you can use readline to go back to previous individual lines, but it doesn't have any "concept" of what a function is, a section of code, etc.

Is there a tool like that for Python? Or, do you have some sort of similar workaround that you use, say, in vim?

  • besides in RStudio there is support for .Rnw files which I find particular useful for creating automated pdf files. I am still looking for a good Python IDE. – moldovean Oct 01 '13 at 08:50
  • 1
    You get to see variables details and most importantly help file within the Rstudio – Ankit Sep 03 '14 at 06:59
  • 28
    Eclipse PyDev, Jupyter, and Spyder/Anaconda are *decent* substitutes, but none of them are as easy to work with as RStudio. The code completion, shortcuts for switching areas, interactive installation of packages, tabs with repositioning of order, documentation pane, all make RStudio easier to use. Python has some huge advantages as a language, but IMHO no Python IDE is on RStudio's level. –  Feb 26 '16 at 13:26
  • 2
    I started using Rodeo, however it is very buggy. Nothing compares to RStudio. Python will always have that weakness for data analysis and exploration until a proper IDE is made with data analysis and exploration as the primary goal. – codingknob Jan 12 '17 at 04:49
  • *"Eclipse PyDev, Jupyter, and Spyder/Anaconda are decent substitutes..."* they are all different things, I don't understand why you pair them together. Eclipse is an IDE, Jupyter is an interactive workbook and Spyder is not even close to PyCharm or the like. Plus, none of them supports most of the features that RStudio has. – gented Mar 24 '17 at 13:17
  • 4
    RStudio now supports Python: https://blog.rstudio.com/2018/10/09/rstudio-1-2-preview-reticulated-python/ – Oliver Oliver May 05 '19 at 23:06

10 Answers10

53

IPython Notebooks are awesome. Here's another, newer browser-based tool I've recently discovered: Rodeo. My impression is that it seems to better support an RStudio-like workflow.

Rodeo screenshot

Ryan
  • 911
  • 8
  • 7
  • 2
    Great find! IMO RStudio is the best UI for data analysis, always looking for something similar for python. – visitantz May 08 '16 at 01:40
  • 4
    Yhat released [Rodeo 2.0](https://www.yhat.com/products/rodeo/) (native app not a browser tool) for Windows, Mac & Linux in 2016. It's a lot more stable than it was and has lots of new features like syntax highlighting and integrated tutorials. Definitely worth checking out if you like RStudio! – Elise Breda Oct 11 '16 at 21:51
  • 10
    My impression in early 2017 is that Rodeo still feels like a very new project and cannot compare to RStudio in terms of features or UI customizations. And it seems quite buggy. I believe [Spyder](https://github.com/spyder-ide/spyder) is much more mature and close to being a real RStudio alternative, but YMMV. – Jealie Jan 16 '17 at 02:34
  • Ad "native app not a browser tool": From what I can see Rodeo 2.0 uses [Electron](http://electron.atom.io/). It still is a browser tool, only it now comes with its own browser to make it feel like its a native app. (It's also worth mentioning that it comes with a dependency on NodeJS.) – Phillip Jan 17 '17 at 10:21
  • 1
    The link provided seems currently (2019-03) to be outdated. I found this thread stating issues with Rodeo in general: github.com/yhat/rodeo/issues/655 – Qaswed Mar 26 '19 at 18:00
34

Jupyter Notebook (previously known as IPython notebook) is a really cool project for interactive data manipulation in Python (and other languages, including R). It basically allows you to interactively code and document what you're doing in one interface and later on save it as a:

  • notebook (.ipynb)
  • script (a .py file including only the source code)
  • static html (and therefore pdf as well)

You can even share your notebooks online with others using the nbviewer service, where people publish whole books. Furthermore, GitHub renders your .ipynb files. You can publish your Jupyter Notebooks as reproducible research articles on Authorea. For collaborative editing by multiple users, check out Google Colab built on top of Jupyter.

Jupyter Notebook Screenshot

The default Jupyter Notebook version starts a web application locally (or you deploy it to a server) and you use it from your browser. As Ryan also mentioned in his answer, Rodeo is an interface more similar to RStudio built on top of the Jupyter kernel.

JupyterLab is a newer take on the UI allowing for more flexibility in how you edit your notebooks, control interactive widgets and even run commands in terminal emulators.

There's also a Qt console for IPython, a similar project with inline plots, which is a desktop application.

Jupyter is a normal Python package and can be installed using pip install jupyter. To get all the scientific libraries running on your computer, however, it might be easier to try the official Jupyter Docker containers. For example, assuming your notebooks are in ~/code/jupyter, you can run the container as:

docker run -it --rm -p 8888:8888 -v ~/code/jupyter:/home/jovyan/work jupyter/datascience-notebook
metakermit
  • 21,267
  • 15
  • 86
  • 95
  • There is a very important difference though: people who have accounts on the machine the RStudio web server is running on, can log in into the server and use it in a "time-sharing" fashion over the same port. IPython 2.x does not support this: if you want 2 people to access it on the same server, you have to run 2 server instances on 2 different ports which does not scale easily. – András Aszódi Feb 13 '15 at 10:05
  • Yes, that's correct. [Initial work in IPython 3.x](https://github.com/ipython/ipython/wiki/Roadmap:-IPython#release-30-fall-2014) is done to support multi-user notebooks, however. – metakermit Feb 13 '15 at 16:32
  • 2
    Another key difference is the (IMHO) ridiculous format of the "notebook." In RStudio you can open a script, pass it to the interpreter, and then interact with the interpreter. The script is on one side, the interpreter on the other. Because IPython has its own format you cannot simply open a script, which if edited in a notebook is in a different format. – Michael Jun 12 '15 at 18:41
  • You can import a script verbatim as a module and tinker with any variables or functions it defines inside the notebook then. In the opposite direction, you can export an IPython notebook as a .py file directly. It's not an IDE for sure, though. – metakermit Jun 13 '15 at 20:31
  • 1
    @kermit666 JupyterHub (https://github.com/jupyter/jupyterhub) is the solution I am currently using for multi-user notebooks accessible over the Web. Works quite nicely. Recommended. – András Aszódi Aug 26 '15 at 13:55
  • This does not answer the OP's question, which was asking about IDE's that let you run a script one line at a time, or just on a given selection of lines. iPython / Jupyter does not do this, as far as I can tell; you can only run on a per-cell basis, not an arbitrary per-line basis. So if you have a chunk of code in a cell, you have to run ALL of it, you can't just selectively run a single line like you can in RStudio. – user5359531 Jun 16 '16 at 18:04
  • Jupyter Notebook is nothing like RStudio, it is like Maple. – Stepan S. Sushko Aug 14 '20 at 11:51
34

spyder or install python(x,y). it is great.

If you are new to Python, you can install the free Anaconda distribution (http://continuum.io/downloads.html), which will install Spyder for you, as well as Python 2.7 and IPython. Spyder is very similar to RStudio.

Ryan
  • 911
  • 8
  • 7
echo
  • 2,666
  • 1
  • 25
  • 17
  • 6
    I've been looking for a workflow like R with a text editor for python for quite some time and spyder seems to do it. I have a text editor window and a python window. I highlight a few lines in the text editor and hit F9 and they run in the interpreter. Simple, but exactly what I was looking for. – kpierce8 Oct 08 '13 at 17:23
  • Spyder is great as a local equivalent of RStudio (though it lacks the easy remote browser access of the server version). – Michael Jun 12 '15 at 18:57
23

Check out Rodeo from Yhat if you're looking for something like RStudio for Python.

Rodeo has:

  • text editor (uses Atom under the hood)
  • Vim / Emacs mode
  • an IPython console
  • autocomplete
  • docstrings
  • ability to see plots, dataframes, variables
Elise Breda
  • 241
  • 2
  • 5
  • 1
    The link provided seems currently (2019-03) to be outdated. I found this thread stating issues with Rodeo in general: https://github.com/yhat/rodeo/issues/655 – Qaswed Mar 26 '19 at 18:00
  • Rodeo has been abandoned by its developer. So there are no updates on this IDE since 2017. In my opinion, Spyder is the next best thing right now. – Rahib Apr 25 '21 at 01:35
21

You might want to look into JupyterLab (the next generation of Jupyter Notbooks): https://github.com/jupyter/jupyterlab.

JupyterLab aims to create a more desktop-like experience on the Web.

Update: As of March 2018 JupyterLab is in beta. "The beta releases are suitable for general usage. For JupyterLab extension developers, the extension APIs will continue to evolve until the 1.0 release. Eventually, JupyterLab will replace the classic Jupyter Notebook after JupyterLab reaches 1.0."

To run Jupyter Lab as a Desktop Application, see christopherroach.com/articles/jupyterlab-desktop-app (Thanks to PatrickT).

Here's a quick preview:

enter image description here

You can arrange a notebook next to a graphical console atop a terminal that is monitoring the system, while keeping the file manager on the left:

enter image description here

For more details see: https://blog.jupyter.org/2016/07/14/jupyter-lab-alpha/ and here: http://www.techatbloomberg.com/blog/inside-the-collaboration-that-built-the-open-source-jupyterlab-project/.

majom
  • 7,863
  • 7
  • 55
  • 88
  • 1
    Looks nice. This opens in your browser (it's so obvious you did not mention it). I find this irritating. I'd set up a dedicated browser if I was to use this. Is there a recommended browser for jupyterlab? – PatrickT Mar 13 '18 at 05:41
15

Pycharm is a really decent IDE. From what I have seen so far it is the most similar to Rstudio. Another nice piece is that it allows you to install new Python libraries in a fashion similar to Rstudio (which otherwise can be a nightmare). There is now a free 'community' edition.

enter image description here

mmann1123
  • 5,031
  • 7
  • 41
  • 49
  • I might add that it has support for jupyter/ipython files, so you could combine it with the top answer. (Not sure if that's part of the free version). – Mark Sep 29 '16 at 12:24
  • PyCharm also let's you run a selection of code too! – 4d11 Feb 14 '18 at 19:33
7

I think it is worth while to mention that RStudio v1.1.359 Preview is released. It has terminal feature that can be used for Python.

Download is available here

Documentation is available here

Naren Murali
  • 19,250
  • 3
  • 27
  • 54
sankalp
  • 81
  • 1
  • 3
4

spyder is you need! https://code.google.com/p/spyderlib/
Spyder (previously known as Pydee) is a powerful interactive development environment for the Python language with advanced editing, interactive testing, debugging and introspection features

duhan
  • 41
  • 1
0

Wing IDE, and probably also other Python IDEs like PyCharm and PyDev have features like this. In Wing you can either select and execute code in the integrated Python Shell or if you're debugging something you can interact with the paused debug program in a shell (called the Debug Probe). There is also special support for matplotlib, in case you're using that, so that you can work with plots interactively.

Wingware
  • 896
  • 5
  • 12
0

For a nicer interactive shell for Python, have a look at DreamPie. It's not really an IDE though (as RStudio seems to be?)

Steven
  • 28,002
  • 5
  • 61
  • 51