# I can't make my add-on to be configurable from the add-on manager although I've followed the manual's directions

**URL:** <https://forums.ankiweb.net/t/i-cant-make-my-add-on-to-be-configurable-from-the-add-on-manager-although-ive-followed-the-manuals-directions/20853>\
**Category:** Development\
**Created:** [June 17, 2022, 4:45pm UTC](https://forums.ankiweb.net/t/i-cant-make-my-add-on-to-be-configurable-from-the-add-on-manager-although-ive-followed-the-manuals-directions/20853 "2022-06-17T16:45:05Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![gbrl.sc](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@gbrl.sc](https://forums.ankiweb.net/u/gbrl.sc)\
**Post date:** [June 17, 2022, 4:45pm UTC](https://forums.ankiweb.net/t/i-cant-make-my-add-on-to-be-configurable-from-the-add-on-manager-although-ive-followed-the-manuals-directions/20853/1 "2022-06-17T16:45:05Z")

</div>

I followed the [instructions from the manual](https://addon-docs.ankiweb.net/addon-config.html) but the “Config” button still remains disabled when I select my add-on in the add-on manager.

My addon’s folder contains the following files:

- \_\_init \_\_.py
- add-on.py
- config.json
- config.md  
And a user\_files folder.

The `config.json` file contains a dictionary with two entries.

The `add-on.py` file begins with:

```auto
from aqt import editor, gui_hooks, mw
from aqt.addcards import AddCards
from aqt.utils import *
from aqt.forms import addcards

from datetime import datetime, timedelta
from time import *
import math
import sqlite3
import sys
import pathlib
import json

config = mw.addonManager.getConfig( __name__ )

```

How to solve it?

**Edit** : I tried to implement the example provided in the manual but Anki returns the following error message when I try to open it:

> An add-on you installed failed to load. If problems persist, please go to the Tools\>Add-ons menu, and disable or delete the add-on.
> 
> When loading ‘⁨addOn⁩FromTheManual’:  
> ⁨Traceback (most recent call last):  
> File “aqt.addons”, line 244, in loadAddons  
> File “C:\Users\User\AppData\Roaming\Anki2\addons21\addOn⁩FromTheManual\ \_\_init \_\_.py”, line 1, in   
> from . import addOn⁩FromTheManual  
> File “C:\Users\User\AppData\Roaming\Anki2\addons21\addOn⁩FromTheManual\addOn⁩FromTheManual.py”, line 3, in   
> print(“var is”, config[‘myvar’])  
> TypeError: ‘NoneType’ object is not subscriptable  
> ⁩

**P.s.** I’m using Anki 2.1.53, Python 3.9.6, Windows 10 and Visual Studio Code 1.68.1.

---

<div class="post-metadata">

**Author:** ![abdo](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/abdo/32/654_2.png) [@abdo](https://forums.ankiweb.net/u/abdo)\
**Post date:** [June 17, 2022, 7:56pm UTC](https://forums.ankiweb.net/t/i-cant-make-my-add-on-to-be-configurable-from-the-add-on-manager-although-ive-followed-the-manuals-directions/20853/2 "2022-06-17T19:56:36Z")

</div>

Works for me. The problem is most likely caused by a malformed config.json. getConfig() in this case returns None. Check your JSON or post the file here.

---

<div class="post-metadata">

**Author:** ![abdo](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/abdo/32/654_2.png) [@abdo](https://forums.ankiweb.net/u/abdo)\
**Post date:** [June 17, 2022, 7:58pm UTC](https://forums.ankiweb.net/t/i-cant-make-my-add-on-to-be-configurable-from-the-add-on-manager-although-ive-followed-the-manuals-directions/20853/3 "2022-06-17T19:58:36Z")

</div>

Hint: check for those pesky trailing commas in your config. JSON doesn’t allow for trailing commas like many programming languages.

---

<div class="post-metadata">

**Author:** ![gbrl.sc](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@gbrl.sc](https://forums.ankiweb.net/u/gbrl.sc)\
**Post date:** [June 17, 2022, 8:10pm UTC](https://forums.ankiweb.net/t/i-cant-make-my-add-on-to-be-configurable-from-the-add-on-manager-although-ive-followed-the-manuals-directions/20853/4 "2022-06-17T20:10:11Z")

</div>

Here’s the JSON code:

```auto
{

    "minutes": 40,
    "bars": 2
  
}

```

---

<div class="post-metadata">

**Author:** ![abdo](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/abdo/32/654_2.png) [@abdo](https://forums.ankiweb.net/u/abdo)\
**Post date:** [June 17, 2022, 8:38pm UTC](https://forums.ankiweb.net/t/i-cant-make-my-add-on-to-be-configurable-from-the-add-on-manager-although-ive-followed-the-manuals-directions/20853/5 "2022-06-17T20:38:21Z")

</div>

Looks correct, and I can’t reproduce your issue. The config button works for me with this config. If you can post the full code of the add-on, maybe that will help reveal the issue.

---

<div class="post-metadata">

**Author:** ![gbrl.sc](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@gbrl.sc](https://forums.ankiweb.net/u/gbrl.sc)\
**Post date:** [June 17, 2022, 9:03pm UTC](https://forums.ankiweb.net/t/i-cant-make-my-add-on-to-be-configurable-from-the-add-on-manager-although-ive-followed-the-manuals-directions/20853/6 "2022-06-17T21:03:04Z")

</div>

Sure. I’m making the code looks more neat right now (deleting some functions and variables that doesn’t have use anymore and translating the ones I didn’t write in English) and I’ll share it soon.

Meanwhile, here’s the code I used to reproduce the example provided in the add-on docs:

P.s. This add-on also didn’t have the “Config” button enabled and raised the error I described in the original post. The same error was raised when I tried to run the add-on I’m working on.

> **\_\_init \_\_.py**

```auto
from . import addOn

```

> **addOn.py**

```auto
from aqt import mw
config = mw.addonManager.getConfig( __name__ )
print("var is", config['myvar'])

```

> **config.json**

```auto
{"myvar": 5}

```

> **config.md**

```auto
This is documentation for this add-on's configuration, in *markdown* format.

```

> **meta.json**

```auto
{"name": "addOn", "mod": 0, "min_point_version": 0, "max_point_version": 53, "branch_index": 0, "config": {"myvar": 5}, "disabled": false, "conflicts": [], "update_enabled": false}

```

---

<div class="post-metadata">

**Author:** ![abdo](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/abdo/32/654_2.png) [@abdo](https://forums.ankiweb.net/u/abdo)\
**Post date:** [June 17, 2022, 11:41pm UTC](https://forums.ankiweb.net/t/i-cant-make-my-add-on-to-be-configurable-from-the-add-on-manager-although-ive-followed-the-manuals-directions/20853/7 "2022-06-17T23:41:36Z")

</div>

Also works for me. The getConfig function [returns None](https://github.com/ankitects/anki/blob/67f64740c4175c13bad3e17611820a3e84fa59ac/qt/aqt/addons.py#L624) in mainly two cases:

1. If `config.json` doesn’t exist.
2. If the JSON is not valid.

So, I have no idea why it doesn’t work for you.

> [@gbrl.sc](#):
>
> I’ll share it soon.

Sending a zip of the add-on files will be nice.

---

<div class="post-metadata">

**Author:** ![gbrl.sc](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@gbrl.sc](https://forums.ankiweb.net/u/gbrl.sc)\
**Post date:** [June 17, 2022, 11:49pm UTC](https://forums.ankiweb.net/t/i-cant-make-my-add-on-to-be-configurable-from-the-add-on-manager-although-ive-followed-the-manuals-directions/20853/8 "2022-06-17T23:49:45Z")

</div>

It just came to my mind that the file was saved with the wrong codification, then I applied the UTF-8 codification instead of UTF-8 with BOM and it worked!

By the way, thank you for spending your time to help me once again.

---

<div class="post-metadata">

**Author:** ![gbrl.sc](https://avatars.discourse-cdn.com/v4/letter/g/57b2e6/32.png) [@gbrl.sc](https://forums.ankiweb.net/u/gbrl.sc)\
**Post date:** [June 17, 2022, 11:53pm UTC](https://forums.ankiweb.net/t/i-cant-make-my-add-on-to-be-configurable-from-the-add-on-manager-although-ive-followed-the-manuals-directions/20853/9 "2022-06-17T23:53:57Z")

</div>

> [@abdo](#):
>
> Sending a zip of the add-on files will be nice.

All right. The add-on is almost done. I just have to address some exceptions and finish the process of cleaning the code.

---

<div class="post-metadata">

**Author:** ![abdo](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/abdo/32/654_2.png) [@abdo](https://forums.ankiweb.net/u/abdo)\
**Post date:** [June 18, 2022, 12:07am UTC](https://forums.ankiweb.net/t/i-cant-make-my-add-on-to-be-configurable-from-the-add-on-manager-although-ive-followed-the-manuals-directions/20853/10 "2022-06-18T00:07:02Z")

</div>

> [@gbrl.sc](#):
>
> It just came to my mind that the file was saved with the wrong codification, then I applied the UTF-8 codification instead of UTF-8 with BOM and it worked!

Oh, this is a common source of errors that didn’t come to my mind! I recommend turning on UTF-8 support on Windows 10 to save yourself from headaches: [Is it possible to set "locale" of a Windows application to UTF-8? - Super User](https://superuser.com/questions/1033088/is-it-possible-to-set-locale-of-a-windows-application-to-utf-8)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/8f1279ababc5879d54e4838989f606cfe55af8c7.jpeg) [@system](https://forums.ankiweb.net/u/system)\
**Post date:** [May 1, 2023, 3:15am UTC](https://forums.ankiweb.net/t/i-cant-make-my-add-on-to-be-configurable-from-the-add-on-manager-although-ive-followed-the-manuals-directions/20853/11 "2023-05-01T03:15:22Z")

</div>

Closed on May 1, 2023, 3:15am UTC


