Feature Spotlight: Creating and managing Django projects

Happy Friday everyone,

PyCharm is known for its superior support of the Django web framework. It’s been supported since the inception of PyCharm, and with each release we improve it by polishing the existing features and adding new ones.

With the latest PyCharm 4.5 release, we’ve improved Django 1.8 code insight and added a big new feature: the manage.py console.

This new tool introduces a new user interface and provides autocompletion for manage.py tasks and their arguments. The manage.py console also preserves the command history so you can easily fetch previous commands just by pressing Up / Down arrows. Quick documentation is also supported by pressing Ctrl+Q on a manage.py command.

Note: Django support is available only in PyCharm Professional Edition.

Given the number of big and small changes to Django support, recently we updated our main Creating and managing Django projects tutorial. Do check it out if you are migrating to PyCharm as a new development environment and want to get used to its basics. Or if you just want to revisit the whole picture of Django development with PyCharm.

Talk to you soon,

Posted in Cool Feature, Tutorial | 2 Comments

Quantitative Research in Python: Using Notebooks

This is a first in a series of blog posts covering the use of Python for quantitative research. In this post, we take a look at IPython Notebooks: a really handy tool for structuring calculations in a document-like fashion.

If you look at the state of various computer algebra systems (CASs) today, you will see that they typically operate not only on the basis of a REPL-style console window input, but rather provide a workbook/worksheet/document mechanic whereas the commands to be executed and their results are mixed together. This effectively provides for literate programming and makes it easy to write entire articles/books directly from a CAS.

Mathematica Notebook

Python is no exception: it has taken the world of numerical computing by storm, becoming a serious contender to established programming languages such as MATLAB or R. And indeed, the exact mode of interaction is supported in Python too with the use of IPython Notebooks.

The IPython Notebook

First of all, make sure you’ve actually got Python and IPython. The simpliest way of doing this is to simply install a distribution package that includes lots of pre-built Python tools, such as Contunuum’s Anaconda or Enthought Canopy.

The IPython Notebook support is part of the IPython distribution. Its goal is to provide a web-based document editing experience whereas the user can enter one of two things:

  • Ordinary text (Markdown format) that will be presented as such. Among other things, IPython Notebooks support LaTeX formatting, which is great for rendering formulae.
  • Python code, which is stored in cells. You can execute each of the cells and the output will appear right after the relevant cell.

Here’s what typical interaction with a workbook looks like:

Now, you could be forgiven for thinking that this form of interaction only supports textual output. In actual fact, it supports graphical output too, so you can do data visualizations with libraries such as Matplotlib. Simply import the package and call its APIs and you’ll get the visual output right here on the page:

While the IPython notebooks are great when used on the web, they offer little help when coding. Sure, they report on the errors in your cells, but apart from non-automatic code completion, they do not offer any coding assistance features (e.g., automatic code completion, parameter info, navigation, as-you-type error checking, and so on), so you essentially need to know the API by heart and rely on the interpreter itself to catch your errors. Alternatively, you can just use PyCharm.

Notebooks in PyCharm

Using IPython notebooks in PyCharm is easy, and gives you the benefit of PyCharm’s features such as code completion. Here’s how to do it.

Note: an active IPython notebooks instance is only required for evaluation of Python code. Text rendering is handled by PyCharm itself.

First, create a file with an .ipynb extension. This signals to PyCharm that it’s an IPython notebook.

Second, makes sure an IPython Notebook kernel is running. The simplest way is to simply fire up PyCharm and when you try to evaluate something, you will see the following dialog:


Simply enter the URL and PyCharm will fire up an IPython notebook at this exact location.

Finally, go ahead and edit the cells in the document. Unlike the web interface, PyCharm provides a lot of things: you get code completion, inspections and navigation features that you would expect if you were working with an ordinary Python project:

Press Ctrl+Enter to execute a cell. Note that the cell number gets incremented accordingly. Press Shift+Enter to add a new cell.

If you want to add some text or a heading, use the drop-down menu to pick the appropriate element. Text entries also support LaTeX — use a single $ to delimit inline formulae and two dollars ($$) for display formulae.

Finally, it’s worth noting that PyCharm’s theming is matched in the worksheet, so if you prefer a more article-like feel, this is possible too:

Libraries for Quantitative Analysis

The simplest kinds of libraries that you need for quantitative analysis are mathematical libraries such as NumPy and SciPy. These packages contain a wealth of different numerical method implementations.

When it comes to visualization, there is the excellent matplotlib library that we already mentioned.

And of course there are plenty of wrappers around native libraries available to Python through the power of tools like SWIG. For example, the QuantLib library uses it to generate Python wrappers around its C++ interfaces. It’s not an ideal process, but it does produce a workable package that you can use.

Naturally, Python also has other bindings which might be useful when analyzing and visualizing data. These include things such as tools for building interactive applications (e.g., wxPython) or bindings to NVIDIA CUDA via PyCuda.

So, that’s it for now! Enjoy IPython notebooks!

Posted in Tutorial | Tagged , , | 4 Comments

Meet the PyCharm Team in Bilbao, Spain, at EuroPython 2015

europython-2015-logo-white-bgThe JetBrains PyCharm Team is currently in Bilbao, Spain, for EuroPython 2015 (July 20–26). The conference is held in the Euskalduna Conference Center (ECC, Abandoibarra Etorbidea 4, Bilbao).

EuroPython is the second largest global conference for the popular programming language Python, surpassed only by the PyCon US conference. It is aimed at the entire Python community, from professional programmers to those who are just starting to learn this fantastic language. This year’s event will feature more than 200 sessions, including three by JetBrains:

CAN RUST MAKE PYTHON SHINE?Monday, July 20, at 14:30
by Dmitry Trofimov

Rust is a new programming language from Mozilla. It is fast, safe and beautiful. It is also a very good option when you need performance. In this talk we’re going to look at Rust and see what it offers and how we can leverage it as Python developers. And we’ll do it with a case study: a statistical profiler for Python.

NUMPY: VECTORIZE YOUR BRAINThursday, July 23, at 12:30
by Ekaterina Tuzova

NumPy is the fundamental Python package for scientific computing. However, being efficient with NumPy might require slight changes in how you write Python code.
I’m going to show you the basic idioms essential for fast numerical computations in Python with NumPy. We’ll see why Python loops are slow and why vectorizing these operations with NumPy can often be good.
Topics covered in this talk include array creation, broadcasting, universal functions, aggregations, slicing and indexing. Even if you’re not using NumPy, you’ll benefit from this talk.

by Andrey Vlasovskikh

PEP 484 introduces type hints for Python 3. Type hints can increase the readability of our code for both humans and tools, and lead to better and safer outcomes. And we’ll prove it in this talk!
We’re going to take a closer look at type hints and see practical examples of where they can be used and what value they provide. We’ll see that simple class types and built-in collection types are often enough for our public APIs. We’ll also discuss how you can benefit from type hinting stubs for third-party libraries and briefly cover more advanced scenarios like generic types.

This show represents a great opportunity to meet PyCharm team members, learn about the latest releases, our current developments and future plans, discuss the latest trends in the Python world and related technologies… or just say ‘Hi!’. Stop by our booth in the expo hall, ask questions and share your experiences with PyCharm and other JetBrains products. We’re raffling some PyCharm licenses so be sure to register and grab some of our cool giveaways too!

We look forward to meeting you there. For more information on the EuroPython 2015 conference, please visit its official website.

Develop with pleasure!
PyCharm team

Posted in Conferences & Events | Leave a comment

Announcing the PyCharm 4.5.3 release update

The PyCharm 4.5.3 has been uploaded and is now available from the download page.

It also will be available soon as a patch update from within the IDE (from PyCharm 4.5.x only).

As a recap, this minor bug update delivers the following fixes and improvements:

  • a number of fixes for Django support, mostly related to the new manage.py tool.
  • a bunch of improvements in Python refactorings and the new auto-intention: convert tuple to list and vice-versa which is available on Alt+Enter over the cursor on a list or a tuple.
  • The new option in Python code style settings: “After local imports” on the “Blank lines” tab. Using this field, you can specify the number of blank lines to be inserted after local import inside a function. By default this value is set to 0.
  • a couple of important fixes for Python code insight.
  • a fix for spurious matplotlib messages in the console.
  • a number of fixes for the brand-new Python profiler (including support for Python 2.4 and 2.5).
  • a stunning list of fixes for the integrated Deployment tool.

For further details on the bug fixes, please consult the PyCharm 4.5.3 RC and PyCharm 4.5.3 RC2 release notes.

Download PyСharm 4.5.3 for your platform from our website and please report any problem you found in the Issue Tracker.

If you would like to discuss your experiences with PyCharm, we look forward to your feedback in comments to this post and on twitter.

Develop with Pleasure!
-PyCharm team

Posted in Release Announcements | 1 Comment

Announcing the PyCharm 4.5.3 RC2

Having announced the PyCharm 4.5.3 Release Candidate build two weeks ago, today we’ve published the PyCharm 4.5.3 RC2 build 141.1899, which is already available for download and evaluation from the EAP page.

The full list of fixes and improvements for this build can be found in the release notes. The list is really huge so here are the most notable improvements:

  • a couple of important fixes for Python code insight
  • a fix for spurious matplotlib messages in the console
  • a number of fixes for the brand-new Python profiler (including support for Python 2.4 and 2.5)
  • a stunning list of fixes for the integrated Deployment tool.

Download the PyСharm 4.5.3 RC2 build for your platform from the project EAP page and please report any bugs and feature request to our Issue Tracker. It also will be available shortly as a patch update from within the IDE (from 4.5.x builds only) for those who selected the Beta Releases channel in the update settings.

Stay tuned for a PyCharm 4.5.3 release announcement, follow us on twitter, and develop with pleasure!

-PyCharm Team

Posted in Early Access Preview | 5 Comments

Feature Spotlight: Become more productive with PyCharm

Happy Monday everyone,

Today I’m going to highlight 3 simple things you can do every day to harness the power of PyCharm and steadily increase your productivity.

1. PyCharm Productivity Guide

PyCharm smartly analyzes the features you use most often during your development sessions, and alerts you to some features you may have missed.

The Productivity Guide dialog is available in Help | Productivity Guide, displaying the list of features with usage statistics and tips:


Besides analyzing your personal usage of features, you can discover other similar features that you have yet to try. Simply sort features by Group, and look for unused ones next to the frequently used. For a quick hint on how to use a feature, select it and see the tips below.

2. Keyboard Shortcuts You Cannot Miss

PyCharm is no Vim or Emacs, but you can still do a lot using just your keyboard. As a keyboard-centric IDE, PyCharm has keyboard shortcuts for most of its commands. Here’s a short list of indispensable shortcuts you can’t afford to miss:

Shortcut Description
Ctrl+Shift+A Find action by name
Double Shift Search Everywhere
Alt+Enter Show the list of available intention actions
Alt+F1 Switch between views (Project, Structure, etc.)
Ctrl+Tab Switch between the tool windows and files opened in the editor
Alt+Home Show the Navigation bar
Ctrl+J Insert a live template
Ctrl+Alt+J Surround with a live template
F4 Edit an item from the Project or another tree view
Comment or uncomment a line or fragment of code with a line or block comment
Find class or file by name
Ctrl+D Duplicate the current line or selection
Ctrl+W and Ctrl+Shift+W Incremental expression selection
Ctrl+F Find text string in the current file
Ctrl+Shift+F Find text in the project or in the specified directory
Ctrl+Shift+F7 Quickly view the usages of the selected symbol
Ctrl+NumPad Plus
Ctrl+NumPad -
Expand or collapse a code block in the editor
Ctrl+Space Invoke code completion

For the detailed list of default keyboard shortcuts, see the Keyboard Shortcuts Reference. If you’d like to customize your preferred keymap, refer to the Configuring Keyboard Shortcuts sections.

The default keymap reference is also available as a PDF. To view it, select Help | Default Keymap Reference in the main menu:


You may want to print out this ‘cheat sheet’ and keep it handy, to discover new shortcuts as you go along and get to know PyCharm better.

3. Tips of the Day

One of the most adored features among PyCharm users is Tip of the Day. Tips of the Day provide a huge collection of useful and interesting hints. They show up every time you start PyCharm. If you’ve suppressed these tips before, you can always get them back by going to Help | Tip of the Day and selecting the Show Tips on Startup check-box:


I hope you enjoy learning your way around PyCharm and using its numerous features to boost your productivity. It’s an investment that will definitely pay off.

Talk to you next week,

Posted in Cool Feature | 1 Comment

Feature Spotlight: Editing remote files

Happy Friday everyone!

In today’s blog post I’m going to cover a new feature recently appeared in PyCharm 4.5.x series: editing files directly on remote hosts. In a previous blog post, Feature Spotlight: Python remote development with PyCharm, I covered some basic principles of remote development using PyCharm: how to set up a remote interpreter for your project, vagrant box, VM, or even bare metal machine, and how to set up the deployment of your local project to the remote host. This post supplements the earlier one by focusing on editing files directly on remote hosts.

So let’s get started. At this point I assume you already have a remote host up and running, and the remote interpreter and deployment options properly configured in PyCharm.

At any time during development, you can go to Tools | Deployment | Browse Remote Host. This action will open the dedicated tool window for browsing remote files inside PyCharm:


In this window you can perform some common file operations, like renaming files and directories, changing permissions, copy/paste/delete, as well as creating new files and dirs. But what is most useful here is that you can open any file like you do in the project view:


See that special toolbar at the top of the editor? It tells you that the opened remote file hasn’t been changed yet. So let’s make some changes. Note that when you edit the file, PyCharm provides all the usual goodies like autocompletion, error-checking, quick-fixes, etc.:


When you’re done with changes, the toolbar indicates that the file has been changed and asks you if you want to upload it. Before the actual upload, you might want to compare the changed file with its previous state. Click  on the toolbar to inspect the diff:


You can revert your changes any time, by restoring the file to its previous uploaded version:


Finally, click  to upload your file.

I hope this feature makes your remote development even easier.

Have a nice weekend, and talk to you next week!

Posted in Cool Feature | 4 Comments

PyCharm 4.5.3 RC is available

Today we’ve published the PyCharm 4.5.3 RC bug-fix update.

The Release notes lists all fixes from the previous PyCharm 4.5.2 update. The most notable among them are:

  • a number of fixes for Django support, mostly related to the new manage.py tool.
  • a number of fixes for the Python formatter, especially PY-16078: changing the default right margin to 99 symbols according to PEP8.
    Note: This parameter is configurable. You can change its value in Settings(Preferences) | Editor| Code Style | Python | Wrapping and Braces | Right margin
  • a bunch of improvements in Python refactorings and the new auto-intention: convert tuple to list and vice-versa which is available on Alt+Enter over the cursor on a list or a tuple.

Additionally, this build introduces the new option in Python code style settings: “After local imports” on the “Blank lines” tab. Using this field, you can specify the number of blank lines to be inserted after local import inside a function. By default this value is set to 0.

Download PyСharm 4.5.3 RC for your platform from the project EAP page and please report any bugs and feature request to our Issue Tracker. It will be available shortly as a patch update from within the IDE as well. Make sure you’ve selected the Beta Releases channel in update settings.

Develop with Pleasure!
-PyCharm team

Posted in Early Access Preview | 1 Comment

Interview with Pedro Kroger, Author of Modern Python Development with PyCharm

coverPublished earlier this year, Modern Python Development with PyCharm by Dr. Pedro Kroger reveals the best Python programming practices while using PyCharm. Relying on his 20 years of extensive programming and using different programming tools, in his book Dr. Kroger delves into essential topics of setting up PyCharm for your needs and then get the most out of its numerous development features, ranging from the editor basics and essential shortcuts all the way to specialized tools for remote development, version control and web programming. Modern Python Development with PyCharm is recommended for both beginning Python programmers and those coming to PyCharm from other IDEs or text editors.

Our own Dmitry Filippov seized the opportunity and interviewed Dr. Kroger. Read on to learn more about the man, his programming experience and his vision.

- Hi Pedro, could you tell us a bit about yourself and your day job?

I’m a professor based in Brazil, where I teach music composition, harmony, counterpoint, and music analysis. Although my main background is as a modern classical composer, I’ve been programming for more than 20 years and combining these two skills. For instance, for my Ph.D. I wrote a meta-language for sound synthesis using XML and Tcl. My main research interest these days is to write programs to analyze and understand music. I’ve used Tcl and Lisp in the past, and now I use mainly Python. For example, now I’m writing Python programs to analyze the similarities in Mozart’s, Beethoven’s, and Haydn’s string quartets. It’s a lot of fun!

- Your book says you’ve been using Emacs for more than fifteen years. As a Python programmer, could you tell us why you switched from this great editor over to PyCharm and what it is that still makes PyCharm your IDE of choice?

I still use Emacs a great deal, only less than before. For example, I have yet to find a faster way to rename files in a directory than using dired. At one time I was doing everything using Emacs, including reading email and browsing the web. Although I love its extensibility, Emacs is starting to show its age. This post I wrote years ago shows the length you have to go to get some useful features such as code completion and navigation to work. I love that PyCharm has all these features I mentioned in the post out-of-the-box: all I need to do is to define the Python interpreter and start coding.

- What are your favorite PyCharm features that you can’t imagine working without?

PyCharm has a lot of killer features (fantastic code completion, great debugger, etc.), but I think the biggest selling point for me is the integration of features and languages. Everything works out of the box and in similar ways in Python, JavaScript, HTML, CSS, etc. Also, I have a horrible memory, so code completion and inspection helps a great deal.

- How much time did it take you to learn PyCharm from scratch? Do you think learning tools is a big part of a developer’s trade?

It didn’t take too long, since it has a gentle learning curve. On the other hand, it’s packed with features, so I guess I’m still discovering new things every day.
I think learning tools is essential, even if only to know how things are done on “the other side.” For instance, I’ve been learning Vim to understand how I can be more efficient editing text (and PyCharm has a great Vim plugin!).

- Every serious project is not only about Python. It often involves testing, isolation of environment, deployment, version controlling, database management. How does Pycharm help you manage all this stuff?

I love that PyCharm has support for all these things, but to be honest I use the command line or specialized tools (such as Tower for version control, Fabric for deployment) for most of these tasks. I’ve been using them for so long that they are second nature to me. I do run tests using PyCharm though. I love to see the big green bar :-)

- What other developer tools help you be more productive? Would you recommend any to other Python developers?

It’s hard to make recommendations because everyone has a different need. I guess the best thing is to focus on the basics: learn your shell, version control tool, editor, etc., and try not be religious about it. Use the best tools for the best job.

- There are several Web frameworks backed by Python, including Django, Flask, Pyramid, and Google App Engine. What are your personal and professional preferences?

I’m not much of a web developer, although I have done some small projects using Django and Flask and I like both. If I were going to work professionally as a web developer, I’d pick Django. I like the focus on batteries included, great documentation, and stability.

- Python is an open-source project and everything around it is open source as well. In your opinion, how does the open-source concept influence and shape the enterprise software? Have you used any open-source projects in your professional career? Which ones do you like the most?

I think free/open source is fundamental. Many things we take for granted today (such as Google search) was built using open source. Also, open source is essential for education. I use a lot of open source programs, including Linux, FreeBSD, Music21 for music analysis, LaTex, Pandas, and so on.

- There are two major versions of Python currently co-existing: 2.x and 3.x. What do you think about the current state of Python? What’s your take on the future of the language?

I don’t understand the naysayers. Python 3 is a great language and its future is bright. Unlike some languages that tried to reinvent themselves and never delivered, Python 3 is here now and most big and important libraries have been ported. I think 2016 will be the year of Python 3 :-)

- What do you think makes Python unique as a language?

Python is a great language because it’s super powerful and yet has a gentle learning curve, not to mention loads of libraries and tools. I have taught both Lisp and Python to non-programmers and, although one can learn the basics of both in a few hours, Python wins for having more available out of the box.

- What do you think about Python as a language for teaching and learning programming? How can tools help learners to harness the learning curve?

As I mentioned in the previous answer, Python is a great language for teaching. When I teach, I like to start by using a functional approach (since most people have learned functions in high school) and move to classes afterwards. In same languages you have to start with classes from day one, which in my experience makes things more difficult for the beginners. The main roadblock when I was teaching was finding an appropriate editor for the students. If the tool is too difficult, the student has two things to learn; the language and the tool. I haven’t tried the PyCharm Educational Edition yet, since I’m not teaching programming these days, but it looks great!

- Please recommend two other books on development you enjoyed reading recently or just consider important.

The development books I read these days are specific to what I’m working on. For example, the last book I read was Python for Data Analysis, by Wes McKinney, which is only suitable for those interested in data analysis. Although these are not Python books, I highly recommend Structure and Interpretation of Computer Programs by Harold Abelson and Gerald Jay Sussman and Paradigms of Artificial Intelligence Programming by Peter Norvig. There is a lot of beautiful code in these books.

- Thank you for the interview, Pedro!

You can buy Modern Python development with PyCharm on Dr. Kroger’s website. He also runs his own blog, so don’t forget to check it out!

Dr. Pedro Kroger

I’m a programmer, classical composer, bootstrapper, and class clown who loves teaching and traveling. I live now in colorful Salvador (Brazil). I also lived in Austin, San Francisco (USA), Rome (Italy) and London (UK). more …

Posted in interview | Leave a comment

Feature Spotlight: Python Code Coverage with PyCharm

Happy Friday everyone!

Hopefully, most of us are aware of what code coverage is and how it’s being used in the software development process. It helps ensure that our code actually is executed and what’s equally important, our tests actually are testing our code. This is essential for any software written in any language, including Python.

I’ve already covered how PyCharm helps you write clean, quality, maintainable code as well as test it with the integrated graphical test runner. This post will supplement earlier blog posts by highlighting Code Coverage support available in PyCharm.

Basically, everything is quick and simple. To collect coverage statistics, all you need to do is have your code open in PyCharm, have the project Python interpreter specified in the project settings, and have one or several run configurations (preferably including some configurations for tests).

In this short example, I have a project open in PyCharm, with Python interpreter defined in the project settings:


This project contains some tests, which can be run by the nose testing framework. I define the test configuration in PyCharm by clicking “Edit configurations”:


After that, I specify my new ‘Nosetest_run’ configuration in the dialog:


So now I’m able to run my code using this configuration in different modes, including simple run, debug, profiler, and especially ‘Run with Coverage’:


When done, PyCharm gives me the full report on the test run, including coverage data:


Browse the coverage tool window to check the coverage percentage for each directory or file. You can also navigate to any file straight from this tool window, as well as perform other common actions like “Generate Coverage Report” which will show you the full coverage report in HTML:


Note that you can inspect the result of the coverage report right inside the editor. In the left-hand editor gutter, PyCharm marks covered lines with green, and uncovered ones in red:


By the way, PyCharm uses the standard coverage.py tool created by Ned Batchelder. To have it working, make sure it’s installed on your project interpreter (check your PyCharm project settings).

That’s it! I hope you try this very useful code coverage integration and make use of it often.

Just in case you’re craving for more details, check out the official PyCharm documentation.

Talk to you soon,

Posted in Cool Feature | Leave a comment