Thonny 4 packages vs plug-ins path

493 views
Skip to first unread message

tabreturn

unread,
Apr 25, 2022, 12:00:36 AM4/25/22
to thonny
I see that Thonny 4 stores its plug-ins in a separate directory, isolating them from the scripts the user may write and run. So, In Thonny 4, you have --

a packages directory:
/home/<user>/.local/lib/python3.10/site-packages
and a plug-ins directory:
/home/<user>/.config/Thonny/plugins/lib/python3.10/site-packages

In Thonny 3, these are the same location (/home/<user>/.local/lib/python3.9/site-packages)

The problem is that I've developed a plug-in (thonny-py5mode) with packages (dependencies) that I also require for running scripts in the editor. I suppose I could install the plug-in twice -- using "Manage packages" and "Manage plug-ins", but that's redundant and makes installing the plug-in a clumsy, two-step process.

Any suggestions on how to resolve this? 

Thanks. T

Aivar Annamaa

unread,
Apr 25, 2022, 8:08:02 AM4/25/22
to thonny
You could try appending Thonny's plug-in folder to sys.path in your back-end plugin. Search for the usages of thonny.get_sys_path_directory_containg_plugins()

Best regards,
Aivar

tabreturn

unread,
Apr 27, 2022, 12:13:10 AM4/27/22
to thonny
Thanks for the direction, Aivar! I'll look into that.
T

tabreturn

unread,
May 5, 2022, 3:28:06 AM5/5/22
to thonny
Okay -- so your suggestion fixed the issue on Linux. I added a line like this --
sys.path.append(get_sys_path_directory_containg_plugins())

But this doesn't seem to work on macOS? Packages in the plug-ins directory aren't found when I run a script from Thonny.
For example, I install cowsay as a plug-in, the write a script with "import cowsay", and I get a ModuleNotFoundError.

Thanks in advance
T
On Tuesday, April 26, 2022 at 12:08:02 AM UTC+12 aivar....@gmail.com wrote:

tabreturn

unread,
May 9, 2022, 6:30:02 PM5/9/22
to thonny
Sorry to bump this. Any idea's what's causing this?

Aivar Annamaa

unread,
May 10, 2022, 12:25:31 AM5/10/22
to thonny
Thanks for the reminder!

I now investigated this and realised my suggestion doesn't work, as Thonny restores original sys.path after loading plugins. I have no idea how did you get this working on Linux.

I'll change this for the next beta.

Best regards,
Aivar
Reply all
Reply to author
Forward
0 new messages