Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError on Windows 10 #202

Closed
qool-naym opened this issue Dec 19, 2020 · 6 comments
Closed

ImportError on Windows 10 #202

qool-naym opened this issue Dec 19, 2020 · 6 comments

Comments

@qool-naym
Copy link

Hi, I've been using pyo for quite some time on my Mac but now have to set it up on Windows 10 for a project.
Pip installed pyo on Python 3.7 and this is the exact Python version:
Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 16:30:00) [MSC v.1900 64 bit (AMD64)] on win32

That's the pyo path:
c:\users\qooln\appdata\local\packages\pythonsoftwarefoundation.python.3.7_qbz5n2kfra8p0\localcache\local-packages\python37\site-packages (1.0.3)

Just wanted to make sure everything works by importing pyo and then running the script but apparently the module can't be found.
That's the error I'm getting:

Traceback (most recent call last):
  File "c:/Users/qooln/Documents/pyo-test.py", line 1, in <module>
    import pyo
  File "C:\Users\qooln\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pyo\__init__.py", line 28, in <module>
    from .lib import analysis as analysis
  File "C:\Users\qooln\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pyo\lib\analysis.py", line 32, in <module>
    from ._core import *
  File "C:\Users\qooln\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pyo\lib\_core.py", line 58, in <module>
    from .._pyo import *
ImportError: DLL load failed: The specified module could not be found.

Either import pyo and from pyo import * results in an ImportError.

I've already tried to pip3 install pyo but requirement is already satisfied as I've got only one Python version installed.

py -3.7 -m pip install -U pyo
gives me this error:

py : The term 'py' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ py -3.7 -m pip install -U pyo
+ ~~
    + CategoryInfo          : ObjectNotFound: (py:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Haven't tried to install pyo in venv though as I can't use a virtual env for this particular project anyways.
I'm new to Windows, so couldn't really find out what the issue is here (probably anything path related, right?) or even where to start.
Any help would be highly appreciated!!

Cheers!

@belangeo
Copy link
Owner

belangeo commented Dec 19, 2020 via email

@qool-naym
Copy link
Author

qool-naym commented Dec 19, 2020

Hi Olivier,
thanks for looking into this!

I had Python installed via that Windows application manager thingy as it popped up when I checked for any installed Python versions via power-shell.
After uninstalling it again and then reinstalling it with the executable file from python.org I was able to successfully import pyo :)
Just had some issues when booting server, but got it fixed by changing winhost.
One thing remains unsolved though: Usually I would run my scripts without the pyo GUI as so (just a short example):

from pyo import *

s = Server(sr=44100, nchnls=2, buffersize=500, duplex=0, winhost="directsound")

s.setInOutDevice(9)
s.boot()

a = Sine(freq=80, mul=1).mix(2).out()

while True:
   time.sleep(.1)

Unfortunately this doesn't work just yet on the Windows setup. The script runs but outputs no sound.
With s.gui(locals()) everything works fine.

@qool-naym
Copy link
Author

Got it sorted with:

running = True
while running:
    time.sleep(.1)

Thanks again for your help Olivier!

@belangeo
Copy link
Owner

Few comments...

s = Server(sr=44100, nchnls=2, buffersize=500, duplex=0, winhost="directsound")

directsound is the default on Windows, so I guess that it's duplex=0 that solved your problem. Is there an audio input configured on the system?

running = True
while running:
    time.sleep(.1)

This is real bad habit... You have to force quit your program, leaving the audio server booted. That can put your system in an unstable state... What about:

ret = input("Press any key to quit...")
s.shutdown()

Or you can launch you script with -i flag to switch in interpreter mode after running your commands:

python3 -i my_script.py

You can then call shutdown() on the server manually before exiting...

@qool-naym
Copy link
Author

Thanks for the advice!!!!!
Actually s.shutdown() might be solving an issue I've been having on the Windows setup - Heavy glitches appearing after restarting the script. Shame on my not paying attention to shutting down the server before ctrl c force quitting.
On my Mac I've been working with a Motu Ultralite Mk4 and never had any issues even with time.sleep(), I guess that's
why I just stuck with that bad habit ¯_(ツ)_/¯
I had to set up pyo on the Windows machine with the shitty onboard sound card as the Marian Seraph 8+ I ordered had not arrived yet, so the onboard sc must have had issues with the audio server not being closed properly. Also the onboard doesn't have an input, usually I would have set duplex to 1 on the Motu and will certainly do that on the Marian card as well.

Thanks again for your help and advice! The server shutdown method will be helping quite A LOT in the future, still can't
believe that I've never really spent even a split second to think about it when working with audio servers - until today :D

Cheers!

@belangeo
Copy link
Owner

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants