Saturday, November 3, 2012

How To Create a PyCharm Launcher on Ubuntu 12.10

I'm absolutely loving using PyCharm for my Python and Django development, but one of the lingering things I've been meaning to nail down once and for all is creating a launcher for PyCharm in Ubuntu 12.10. Despite the automated way you can attempt to do this from within PyCharm itself and all the other recommendations I've read I was unable to get it working.

In the mean time I also bought of copy of IntelliJ IDEA when they had some crazy back to school sale a couple of months ago (I still dabble in Groovy and Grails a bit). I was having the same issues with creating a launcher for IDEA and the typical tricks I use for Eclipse weren't working, but luckily I came across this post that explains how to do it. The only change I made is pointing to idea64.vmoptions instead of just idea.vmoptions -- other than that it works great.

That got me thinking -- since PyCharm and IDEA are both made by JetBrains, and both run on Java, chances are how they work is pretty darn similar. So I decided to copy the IDEA launcher script and modify it for PyCharm, and lo and behold it worked!

Here's my modified version of the IDEA launcher that works for PyCharm.

#!/bin/bash

export JAVA_HOME=/opt/java/jdk1.7.0_09
export JDK_HOME=/opt/java/jdk1.7.0_09

export PYCHARM_HOME=/home/mwoodward/pycharm-2.6.2

export PYCHARM_VM_OPTIONS="$PYCHARM_HOME/bin/pycharm64.vmoptions"
export PYCHARM_PROPERTIES="$PYCHARM_HOME/bin/idea.properties"

cd "$PYCHARM_HOME/bin"
export LIBXCB_ALLOW_SLOPPY_LOCK=1

./pycharm.sh

Obviously adjust all the paths as necessary for your machine. Make sure you chmod +x on the file, and with that in place you can open up Main Menu (sudo apt-get install alacarte if you don't already have it installed) and add a launcher. For reference the icon lives in PyCharm's bin directory.

Hope that helps someone else who has run into this issue.

3 comments:

edwardbeckettx said...

Nice Post Matt ... BTW ...

I'm pretty sure if you export the env var IDEA_JDK to JAVA_HOME you can get Intellij running on your JDK of choice too ...

Matt Woodward said...

Nice -- thanks for the tip!

edwardbeckettx said...

NP :-)