PyCharm Debugging Help

Posted on
Mon Jul 11, 2022 8:46 pm
indy offline
Posts: 23
Joined: Nov 15, 2014
Location: Auckland, New Zealand

PyCharm Debugging Help

Hello

I'm trying to work on an existing plugin (https://github.com/kmarkley/Indigo-Timed-Devices) to see if I can get it to work with Indigo 2022.1.

I have used Anaconda to setup virtual environments for Python development in the past so I have created a new environment. I've attached the configuration of the environment as well as the packages installed in it

conda_config.txt
Anaconda environment info and package info
(2.55 KiB) Downloaded 60 times


I am using the latest pro version of PyCharm

2022-07-12_15-11-29.png
PyCharm Version
2022-07-12_15-11-29.png (36.97 KiB) Viewed 1311 times


I've followed the wiki article: https://wiki.indigodomo.com/doku.php?id ... nvironment and successfuly set up PyCharm debugging environment. I can start the debugger in PyCharm and have it listen on localhost port 5678

2022-07-12_14-42-20.png
PyCharm Debugger
2022-07-12_14-42-20.png (228.98 KiB) Viewed 1316 times


In Indigo, when I go and reload the plugin via Plugin > Timed Devices > Reload in debugger, it appears that Indigo is not able to connect to PyCharm debugger.

2022-07-12_14-44-32.png
Indigo Plugin Reload
2022-07-12_14-44-32.png (231.37 KiB) Viewed 1316 times


Would appreciate any pointers on how to get this work.

Thanks

Posted on
Tue Jul 12, 2022 5:22 am
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: PyCharm Debugging Help

Are you able to import pydevd from within the Indigo Scripting Shell?

Code: Select all
Python 3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0.29.30)]
Connected to Indigo Server v2022.1.2, api v3.1 (localhost:1176)
>>> import pydevd
>>>
Within the plugin you're working on, be sure that you've set the Server API to 3.0 -- I'm nearly certain that `pydevd` is included in the Indigo Plugin Host 3 (IPH3) only.

Code: Select all
   <key>ServerApiVersion</key>
   <string>3.0</string>

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Jul 12, 2022 8:33 am
jay (support) offline
Site Admin
User avatar
Posts: 18219
Joined: Mar 19, 2008
Location: Austin, Texas

Re: PyCharm Debugging Help

1) Indigo will not run in a virtual environment because it doesn't run in a standard python environment (rather, it runs in an IndigoPluginHost3 process). Setting one up in PyCharm does nothing since no python code is actually run by PyCharm.
2) You do not need to install pydevd - Indigo will get it directly from the PyCharm bundle. PyCharm must be installed in the /Applications directory for Indigo to find the pydevd module. JetBrains makes a custom version of pydevd, and they must be exactly the same module for it to work reliably (thus we just point to the exact same .egg that PyCharm uses).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jul 12, 2022 12:08 pm
indy offline
Posts: 23
Joined: Nov 15, 2014
Location: Auckland, New Zealand

Re: PyCharm Debugging Help

Thanks Jay and DaveL17.

Very helpful to understand about Anaconda and Indigo.

I'm still learning how it all hangs together.

To close the loop...

pydev could be imported in the console. I didn't have to make any changes.

2022-07-13_04-59-07.png
pydev in console
2022-07-13_04-59-07.png (25.17 KiB) Viewed 1276 times


ServerAPIVersion was 2.0. Changed that to 3.0.

This fixed the pydev import error. DaveL17, you were right about this.

I then went into the code for the plugin and updated modules etc. to make them compatible with Python 3.0. Turned out to be a pretty simple task as there were a couple of small changes needed.

The Timed-Devices plugin now works on Indigo 2022.1. Currently the changes exist in my fork of the original plugin code (https://github.com/indynz/Indigo-Timed-Devices)

I have sent a pull request to the author (https://github.com/kmarkley/Indigo-Timed-Devices)

Posted on
Tue Jul 12, 2022 1:40 pm
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: PyCharm Debugging Help

Glad you were able to figure it out.

It's a bit of a steep hill to climb (depending on your Python coding chops). It took me a while to internalize it, but that's probably more to do with my newness with PyCharm (at the time) than anything else.

One important note with PyCharm debugging and Indigo: With each new major version of Indigo, you'll need to point PyCharm to the new plugin location.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Jul 12, 2022 1:55 pm
jay (support) offline
Site Admin
User avatar
Posts: 18219
Joined: Mar 19, 2008
Location: Austin, Texas

Re: PyCharm Debugging Help

DaveL17 wrote:
With each new major version of Indigo, you'll need to point PyCharm to the new plugin location.


I suspect you could get really clever with symlinks to avoid this, but I don't find it an undue burden since its a pretty simple change in the run configuration.

Though, on second thought, maybe not... :D

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Jul 12, 2022 3:28 pm
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: PyCharm Debugging Help

I agree it's not a big deal.

Getting clever would be a lot more work! :D

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests