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.
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:
Changing this to use the pyenv virtualenv Python path for the project fixed things, and allowed me to debug my script.
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:
- If you want to learn more about pyenv and pyenv virtualenv and why they’re awesome, you can check out my previous post!