Getting PyCharm to work with pyenv local

October 7, 2015
python pycharm pyenv

I write the majority of my code in Sublime Text, favouring it over a full blown IDE like PyCharm or Eclipse. However, I cannot argue with the debugging abilities that an IDE provides.

Recently I tried to use PyCharm’s debugging functionality, and although when adding the folder as a PyCharm project and specifying the relevant pyenv virtualenv1 Python path (see image below), PyCharm just could not seem to find it.

pyenv-add-project

After a bit of prodding and poking, I discovered that in the main PyCharm preferences, the Project Interpreter was still set to the pyenv global Python version, like so:

pyenv-interpreter-3.4.3

Changing this to use the pyenv virtualenv Python path for the project fixed things, and allowed me to debug my script.

pyenv-interpreter-virtualenv

This was definitely not an obvious fix (although admittedly I have very little PyCharm experience), so I hope it helps someone else out. I know I’ll refer back to this when I inevitably run into the same issue again in ~6 months!

Notes:

  1. If you want to learn more about pyenv and pyenv virtualenv and why they’re awesome, you can check out my previous post!