belangeo / pyo

Python DSP module
GNU Lesser General Public License v3.0
1.28k stars 130 forks source link

ImportError on Windows 10 #202

Closed qool-naym closed 3 years ago

qool-naym commented 3 years ago

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 commented 3 years ago

Hi,

How did you install Python? The path looks weird... Can you try with the regular cpython from python.org (which should also include the py launcher)?

Olivier

On Sat, Dec 19, 2020 at 7:57 AM qool-naym notifications@github.com wrote:

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 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 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 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 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!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/belangeo/pyo/issues/202, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXKJTFQ3NLM6UTFVYWOVUDSVSPMZANCNFSM4VCI3XYQ .

qool-naym commented 3 years ago

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 commented 3 years ago

Got it sorted with:

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

Thanks again for your help Olivier!

belangeo commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

:+1: