# No console output? (for add-on developing)

**URL:** <https://forums.ankiweb.net/t/no-console-output-for-add-on-developing/20215>\
**Category:** Help\
**Created:** [May 23, 2022, 3:34pm UTC](https://forums.ankiweb.net/t/no-console-output-for-add-on-developing/20215 "2022-05-23T15:34:59Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![learningwithanki](https://avatars.discourse-cdn.com/v4/letter/l/53a042/32.png) [@learningwithanki](https://forums.ankiweb.net/u/learningwithanki)\
**Post date:** [May 23, 2022, 3:34pm UTC](https://forums.ankiweb.net/t/no-console-output-for-add-on-developing/20215/1 "2022-05-23T15:34:59Z")

</div>

Apologies if I missed something basic (new developer here): I have setup PyCharm on Mac with Python 3.10 following the [official guide](https://addon-docs.ankiweb.net/intro.html). I have created a test addon file, added it to the addon folder and got it to work. I have now included a `print('hello world')` in my test function (see screenshot). However, I don’t get any output at all to my console when I activate the addon in the Anki app. Is there anything else in addition to running `/Applications/Anki.app/Contents/MacOS/anki` in the terminal that I need to do?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/2X/1/1459a87a9dddf96d4405d1e14536e186465e6c8a.jpeg)

---

<div class="post-metadata">

**Author:** ![dae](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/dae/32/65_2.png) [@dae](https://forums.ankiweb.net/u/dae)\
**Post date:** [May 24, 2022, 3:22am UTC](https://forums.ankiweb.net/t/no-console-output-for-add-on-developing/20215/2 "2022-05-24T03:22:27Z")

</div>

Maybe you’ll have more luck running Anki from Terminal.app instead of inside PyCharm’s built-in terminal?

---

<div class="post-metadata">

**Author:** ![learningwithanki](https://avatars.discourse-cdn.com/v4/letter/l/53a042/32.png) [@learningwithanki](https://forums.ankiweb.net/u/learningwithanki)\
**Post date:** [May 24, 2022, 8:59am UTC](https://forums.ankiweb.net/t/no-console-output-for-add-on-developing/20215/3 "2022-05-24T08:59:17Z")

</div>

Thanks Damien. Unfortunately still nothing showing up in my console (both PyCharm’s built-in terminal and mac’s terminal.app). No idea what I am doing wrong here…

---

<div class="post-metadata">

**Author:** ![BlackBeans](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/blackbeans/32/2283_2.png) [@BlackBeans](https://forums.ankiweb.net/u/BlackBeans)\
**Post date:** [May 24, 2022, 7:45pm UTC](https://forums.ankiweb.net/t/no-console-output-for-add-on-developing/20215/4 "2022-05-24T19:45:42Z")

</div>

Next step in debugging would probably be trying to save to a file instead of printing (just to ensure you are reaching that line), with

```python
with open("easy/to/reach/path", "w") as f:
    f.write("Hello, world!")

```

If that works, but not the print version, then I would check if the output is not (for some reasons) redirected _somewhere_ (I _assume_ Anki wouldn’t redirect its output, but who knows…), looking at the result of `os.readlink(f"/proc/self/fd/{sys.stdout.fileno()}")` (I’m not sure whether this works on MacOS, but it should since OS X is unix-compliant). It should be the same as if you opened a new python instance and ran that command (in the case it’s not redirected).

---

<div class="post-metadata">

**Author:** ![learningwithanki](https://avatars.discourse-cdn.com/v4/letter/l/53a042/32.png) [@learningwithanki](https://forums.ankiweb.net/u/learningwithanki)\
**Post date:** [May 24, 2022, 11:02pm UTC](https://forums.ankiweb.net/t/no-console-output-for-add-on-developing/20215/5 "2022-05-24T23:02:11Z")

</div>

Thanks BlackBeans! So: I managed to save to a file (as you suggested) - meaning I do reach that line of code and it is executed correctly, however I am having issues running `os.readlink(f"/proc/self/fd/{sys.stdout.fileno()}")` as I am getting different errors.

Correct me if I am wrong, but it seems like in my case Anki is redirecting its output somewhere else (i.e. not to stdout = terminal, correct?). Isn’t there a simple terminal command, which would redirect Anki’s output back to stdout?

---

<div class="post-metadata">

**Author:** ![BlackBeans](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/blackbeans/32/2283_2.png) [@BlackBeans](https://forums.ankiweb.net/u/BlackBeans)\
**Post date:** [May 25, 2022, 5:48pm UTC](https://forums.ankiweb.net/t/no-console-output-for-add-on-developing/20215/6 "2022-05-25T17:48:33Z")

</div>

Usually, when you redirect output, you don’t say output doesn’t go to stdout anymore: stdout is, by definition, where output goes. Instead, you say `stdout = where I want my output to go from now one` and you can’t restore it unless you kept a “backup” of it beforehand.

---

<div class="post-metadata">

**Author:** ![dae](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/dae/32/65_2.png) [@dae](https://forums.ankiweb.net/u/dae)\
**Post date:** [May 26, 2022, 6:19am UTC](https://forums.ankiweb.net/t/no-console-output-for-add-on-developing/20215/7 "2022-05-26T06:19:31Z")

</div>

> [@learningwithanki](#):
>
> Thanks Damien. Unfortunately still nothing showing up in my console (both PyCharm’s built-in terminal and mac’s terminal.app). No idea what I am doing wrong here…

That’s odd. Can you attach a screenshot showing you running Anki from Terminal.app with no output appearing? You should be seeing text like “Anki starting…” and so on.

---

<div class="post-metadata">

**Author:** ![learningwithanki](https://avatars.discourse-cdn.com/v4/letter/l/53a042/32.png) [@learningwithanki](https://forums.ankiweb.net/u/learningwithanki)\
**Post date:** [May 26, 2022, 6:50pm UTC](https://forums.ankiweb.net/t/no-console-output-for-add-on-developing/20215/8 "2022-05-26T18:50:38Z")

</div>

Ah maybe we are getting somewhere now. **I do not see “Anki starting…”** anywhere in my terminal. All I do is running `/Applications/Anki.app/Contents/MacOS/anki`in my terminal, which brings me to the screenshot I posted at the top. I then did all the testing.

Perhaps Anki isn’t really “running in my terminal”. I probably miss something very basic here. What exactly do I have to do - besides running the line above in my terminal - to see “Anki starting…” and so on?

Sorry for taking up your time with this one, guys, but I somehow need to get started…

---

<div class="post-metadata">

**Author:** ![dae](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/dae/32/65_2.png) [@dae](https://forums.ankiweb.net/u/dae)\
**Post date:** [May 27, 2022, 2:12am UTC](https://forums.ankiweb.net/t/no-console-output-for-add-on-developing/20215/9 "2022-05-27T02:12:37Z")

</div>

Please make sure /Applications/Anki.app is the latest version of Anki. Typing that command in and pressing enter should be sufficient - could you include a screenshot of what you see after pressing enter?

---

<div class="post-metadata">

**Author:** ![learningwithanki](https://avatars.discourse-cdn.com/v4/letter/l/53a042/32.png) [@learningwithanki](https://forums.ankiweb.net/u/learningwithanki)\
**Post date:** [May 27, 2022, 10:20am UTC](https://forums.ankiweb.net/t/no-console-output-for-add-on-developing/20215/10 "2022-05-27T10:20:14Z")

</div>

This is what I see:

 ![Screenshot 2022-05-27 at 12.19.07](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/2X/9/9aeeabb5924b0048e3f2b7f1e17c77f07868cc84.png)

I am on version ⁨2.1.49 (dc80804a)⁩  
Python 3.8.6 Qt 5.14.2 PyQt 5.14.2

I wanted to upgrade to the latest version a little bit later as some of my other add-ons may break.

---

<div class="post-metadata">

**Author:** ![MIZMU](https://avatars.discourse-cdn.com/v4/letter/m/7993a0/32.png) [@MIZMU](https://forums.ankiweb.net/u/MIZMU)\
**Post date:** [May 27, 2022, 10:48am UTC](https://forums.ankiweb.net/t/no-console-output-for-add-on-developing/20215/11 "2022-05-27T10:48:42Z")

</div>

use “showInfo”:

```auto
from aqt.utils import showInfo

output = ["exmpale", "output", "console"]

def example_console():
    showInfo(str(output))

menu = mw.form.menuCol
menu.addSeparator()
a = menu.addAction('console')
a.triggered.connect(example_console)

```

[result](https://send.magicode.me/send-file/file/28cf1819e61a2871e192124136e1ec1bdf3c5a60/download)

---

<div class="post-metadata">

**Author:** ![BlueGreenMagick](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@BlueGreenMagick](https://forums.ankiweb.net/u/BlueGreenMagick)\
**Post date:** [May 27, 2022, 12:31pm UTC](https://forums.ankiweb.net/t/no-console-output-for-add-on-developing/20215/12 "2022-05-27T12:31:21Z")

</div>

Isn’t 2.1.49 executable file in `/Contents/MacOS/AnkiMac`? Not `/Contents/MacOS/anki` (Which is 2.1.50+)

`print()` works fine on my Mac when I run Anki on terminal. So it’s probably not an ‘Anki’ problem, and some other configuration issue.

---

<div class="post-metadata">

**Author:** ![learningwithanki](https://avatars.discourse-cdn.com/v4/letter/l/53a042/32.png) [@learningwithanki](https://forums.ankiweb.net/u/learningwithanki)\
**Post date:** [May 27, 2022, 12:56pm UTC](https://forums.ankiweb.net/t/no-console-output-for-add-on-developing/20215/13 "2022-05-27T12:56:00Z")

</div>

**100 points for BlueGreenMagick!** You were exactly right. Everything is working now…

---

<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, 4:14am UTC](https://forums.ankiweb.net/t/no-console-output-for-add-on-developing/20215/14 "2023-05-01T04:14:59Z")

</div>


