Friday, April 22, 2016

Debug django and MySQL project with PyCharm community on Mac

The Problem...

I've been using PyCram community edition on and off lately on my Mac. It does some things good and something just annoy me so much that I go back to ST2.
One of them is that you can't debug or run out of the box a django project. I was always getting the missing image error as you can see in the image.

The Solution...

The solution was super simple once I figured out that it was not reading my MySQL install's bin directory.
Steps are as follows:
Click on Run -> Edit Configurations menu option
Click on the '+' icon to create a new one (1)
Enter the name and select the file
Add new Environment variable (2)
Win :)

Here are some images to help you with it. 

First arrow (1) shows the creation of the new Run Config
Second arrow (2) shows where to click to add new Environment Variable.

before you can enter the variable in you need to know where on your system it was installed. For me it is in the default location of /usr/local/mysql/lib

After you click on the Env Var icon add a new key named DYLD_LIBRARY_PATH 
then add in the following value: /usr/local/mysql/lib/:$DYLD_LIBRARY_PATH

After this click Apply and run your new new configuration. If all went well you will see the out put from django's runserver in the bottom of your editor.

You can find me on twitter @LZAntal