Get directory the add-on exists in

I’m currently writing an add-on and I would like to get the path the add-on is stored in so that I can create a log file in that directory containing relevant information of the internal things that my add-on is doing for debugging.

I’ve looked into __name__ and os.getcwd() but none of these get the directory of the add-on. The following is a minimal working example that I’m using to check that I’m actually getting the directory the add-on exists in (sharing it just in case anyone is interested in experiment with them).

import os
import aqt

def my_function():
  message = [__name__, os.getcwd()]

my_action = aqt.qt.QAction("My new action",
import os
import pathlib

# a Path object pointing to the directory where your add-on file is located

# a string representing the directory's full path

# same as above

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.