2

Help, I can't seem to print anything as soon as I call pyo audio server.

It just exits without returning anything.

Even something like this:

from pyo import *
s = Server()
print("this is not printed")
s.boot()
x = 3.4
print(x,"neither are these")

This should be working right? Or am I hugely mistaken?

I am using the python module pyo version 1.0.1 with Python version 3.7.3 run using Python IDLE 3.7

btw: audio output works, I just want printing for debugging purposes

RMPR
  • 3,368
  • 4
  • 19
  • 31
Bob Dole
  • 21
  • 2
  • Can't reproduce the issue, what happens when you input this line by line in a REPL? – RMPR Apr 20 '20 at 08:17
  • wow, it works when run in command prompt. Is this a IDLE problem – Bob Dole Apr 20 '20 at 10:57
  • 1
    What OS? Did you try to use a debugger? – RMPR Apr 20 '20 at 11:31
  • windows 10, no, it is not able to print anything after the line "s = Server()" – Bob Dole Apr 20 '20 at 13:29
  • 1
    I have reproduced this problem on Windows 10 using IDLE, Jupyter Notebook, and VS Code's Interactive Window - as soon as I run `s=Server()`, somehow the output of `print` **gets redirected to the shell that opened the GUI**. – Stadem Jul 07 '21 at 13:49

1 Answers1

4

The problem appears to be redirection of stdout as seen here: stdout redirect from Jupyter notebook is landing in the terminal

The example below worked for me. I don't know whether this fix screws up anything with pyo - I imagine the GUI portion could have some issues - but I have been able to produce the sounds I want after applying this fix.

# %%
import sys
old_stdout = sys.stdout

# %%
print('Hello World') # Outputs 'Hello World'

# %%
s=Server()
print('Hello Server') # No output; 'Hello Server' appears in the terminal that called python to begin with

# %%
sys.stdout = old_stdout
print('Hello Again') # Outputs 'Hello Again'

Stadem
  • 423
  • 1
  • 6
  • 15