Michael Brunton-Spall     About     Archive     Feed

PyCharm – First Impressions

2010-02-03 17:48:56 +0000

Did you see my link a few days ago, about PyCharm being released by JetBrains?  I hope so because it is a very interesting IDE for python and django developers.

Introduction

PyCharm attempts to up the Python IDE stakes, by bringing the expertise of the rather brilliant IntelliJ Java IDE to the python world. The idea is nice, and the execution is good, especially with the Django integration.

Installation

Installation was as simple as downloading the linux tar.gz file and extracting it.

My first issue was that on a 64 bit system, it fails to start up with the message 

Error occurred during initialization of VM
Could not find agent library on the library path or in the local directory: yjpagent

This is because it attempts to load a library for java profiling that is 32bit compatible only.  The easy workaround is to edit bin/pycharm.vmoptions and delete the line "-agentlib:yjpagent=disablej2ee,sessionname=PyCharm".  I think you could also download the 64 bit version of yjpagent and put it in the lib or bin directory, but haven't tried it yet.

Google App Engine

I did open directory and opened an existing Google App Engine project, which opened quite nicely.  I immediately got some nice warnings to let me know that I was not overriding some methods correctly along with a spurious error that self.request and self.response are unresolved attributes.  I guess that's a slight problem, the IDE can't possibly know that webapp.RequestHandler.initialise will be called before the get method, and since the init method doesn't create those attributes the IDE can't be sure that they exist.  

This kind of bug is the exact reason that python IDE's are hard, and not as helpful as in Java.  In Java the fact that RequestHandler has a request attribute would have to be declared in the class.  Since in python it doesn't, the IDE can't tell what type that attribute is, and therefore can't autocomplete the methods on it.  So using this for the App Engine webapp framework is no better than any other application.

Django

I next opened the pure django implementation for this website.  I had a weird issue here.  I use pip and virtualenv to ensure I have the correct version of django installed for each python project I build.  However PyCharm doesn't support a per project set of library dependencies, and my work machine doesn't actually have django installed system-wide.  I installed Django 1.1 system wide, and using Settings -> Python Interpreter -> Reload I was able to get PyCharm to reload.

I was struck by some issues immediately.  Where I was previously doing import home.models I now need to include the project name, so import bruntonspall.home.models.  I also have a funky bit of python path manipulation in my settings.py, unfortunately PyCharm doesn't seem to handle them properly.  So several of my imports did not work anymore, which caused weird warnings everywhere.

Final Thoughts

This is only an early access program, and I will admit that for creating a new project from scratch, for general python programming this is as good an IDE as I've used.  It doesn't handle all of the really weird behaviours that I've started to use in my django projects, but for non-advanced systems it's probably highly useful.

The biggest issue as far as I am concerned is the lack of good support for virtualenv, pip and pythonpath modification in settings.py.  It's possible that I've missed something, and the next few days I'll be using it heavily to test it out and find out what it does well, and what it does poorly.