-1

I use python 3.6, and I am trying to play an audio file with pyo, but when I try to run it, I get this message;

Traceback (most recent call last): File "C:\Python27\pyotest.py", line 1, in from pyo import * File "C:\Python27\pyo.py", line 2, in NameError: name 'Server' is not defined

My code:

from pyo import *

s = Server().boot()
s.start()
sf  = SfPlayer("C:\Users\*****\Music\sound.mp3", speed=1, loop=True).out()
  • 4
    Possible duplicate of [Pyo in Python: name 'Server' not defined](https://stackoverflow.com/questions/51893964/pyo-in-python-name-server-not-defined) – BSMP Aug 21 '18 at 19:28

1 Answers1

2

Looks like you have created the file C:\Python27\pyo.py. So instead of the actual pyo module getting imported, your file gets imported.

Rename the file C:\Python27\pyo.py and any pyc file (C:\Python27\pyo.pyc) associated with it and try again

Sunitha
  • 11,777
  • 2
  • 20
  • 23
  • (or rename it instead of deleting it) – AKX Aug 20 '18 at 08:01
  • I was testing it earlier and I made a file name pyo, but then I deleted it but it still won't work –  Aug 20 '18 at 08:02
  • @Emyeetko. Well, your traceback still refers to the file `C:\Python27\pyo.py`. So it looks like that file still exists. Can you check again there is not file named `pyo.py` or `pyo.pyc` in `C:\Python27\` – Sunitha Aug 20 '18 at 08:04
  • @Sunitha there is a file named 'pyo' and it's type is a compiled python file, and I tried deleting it but when I ran my code, it said 'Traceback (most recent call last): File "C:\Python27\pyotest.py", line 1, in from pyo import * ImportError: No module named pyo' –  Aug 20 '18 at 08:09
  • @Emyeetko. Well. In that case, it looks like pyo module is not installed, or installed on some non-standard location. – Sunitha Aug 20 '18 at 08:12
  • Do you suggest I install it again? –  Aug 20 '18 at 08:15
  • @Emyeetko. If you have already installed, check if your PYTHONPATH is set correctly. I dont use windows, so I cannot recommend how PYTHONPATH should look like – Sunitha Aug 20 '18 at 08:27