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

Installation error: PyError (PyImport_ImportModule) <class 'KeyError'> #99

Open
timholy opened this issue Dec 26, 2023 · 5 comments
Open

Comments

@timholy
Copy link

timholy commented Dec 26, 2023

I am giving this exciting project a try, and getting this:

(@v1.10) pkg> generate VoiceAssist
  Generating  project VoiceAssist:
    VoiceAssist/Project.toml
    VoiceAssist/src/VoiceAssist.jl

shell> cd VoiceAssist/
/tmp/VoiceAssist

(@v1.10) pkg> add JustSayIt
   Resolving package versions...
    Updating `~/.julia/environments/v1.10/Project.toml`
  [d7252348] + JustSayIt v0.3.0
    Updating `~/.julia/environments/v1.10/Manifest.toml`
  [8f4d0f93] + Conda v1.10.0
  [3f0dd361] + DefaultApplication v1.1.0
  [d7252348] + JustSayIt v0.3.0
  [438e738f] + PyCall v1.96.4
  [81def892] + VersionParsing v1.3.0

julia> ENV
Base.EnvDict with 35 entries:
  "SHELL"                 => "/bin/bash"
  "WSL2_GUI_APPS_ENABLED" => "1"
  "WSL_DISTRO_NAME"       => "Ubuntu"
  "WT_SESSION"            => "609e9cbc-878d-4e55-ae9b-ace7cfebe0bf"
  "RISC"                  => "[email protected]"
  "SSH_AUTH_SOCK"         => "/tmp/ssh-hoTUWoBheBCU/agent.76"
  "SSH_AGENT_PID"         => "78"
  "EDITOR"                => "code"
  "NAME"                  => "diva"
  "PWD"                   => "/tmp"
  "LOGNAME"               => "tim"
  "MOTD_SHOWN"            => "update-motd"
  "HOME"                  => "/home/tim"
  "LANG"                  => "C.UTF-8"
  "WSL_INTEROP"           => "/run/WSL/30990_interop"
  "LS_COLORS"             => "rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;…
  "WAYLAND_DISPLAY"       => "wayland-0"
  "JULIA_IMAGE_THREADS"   => "4"
  "LESSCLOSE"             => "/usr/bin/lesspipe %s %s"
  "TERM"                  => "xterm-256color"
  "LESSOPEN"              => "| /usr/bin/lesspipe %s"
  "USER"                  => "tim"
  "DISPLAY"               => ":0"
  "SHLVL"                 => "1"
  "XDG_RUNTIME_DIR"       => "/mnt/wslg/runtime-dir"
  ⋮                       => ⋮

julia> ENV["PYTHON"]
ERROR: KeyError: key "PYTHON" not found
Stacktrace:
 [1] (::Base.var"#717#718")(k::String)
   @ Base ./env.jl:155
 [2] access_env
   @ Base ./env.jl:60 [inlined]
 [3] getindex(::Base.EnvDict, k::String)
   @ Base ./env.jl:155
 [4] top-level scope
   @ REPL[5]:1

julia> using JustSayIt
[ Info: Running `conda config --set pip_interop_enabled true --file /home/tim/.julia/conda/3/condarc-julia.yml` in root environment
[ Info: Running `pip install pywinctl` in root environment
Requirement already satisfied: pywinctl in /home/tim/.julia/conda/3/lib/python3.10/site-packages (0.3)
Requirement already satisfied: typing-extensions>=4.4.0 in /home/tim/.julia/conda/3/lib/python3.10/site-packages (from pywinctl) (4.4.0)
Requirement already satisfied: pywinbox>=0.6 in /home/tim/.julia/conda/3/lib/python3.10/site-packages (from pywinctl) (0.6)
Requirement already satisfied: pymonctl>=0.6 in /home/tim/.julia/conda/3/lib/python3.10/site-packages (from pywinctl) (0.7)
Requirement already satisfied: python-xlib>=0.21 in /home/tim/.julia/conda/3/lib/python3.10/site-packages (from pywinctl) (0.33)
Requirement already satisfied: six>=1.10.0 in /home/tim/.julia/conda/3/lib/python3.10/site-packages (from python-xlib>=0.21->pywinctl) (1.16.0)
ERROR: InitError: PyError (PyImport_ImportModule) <class 'KeyError'>
KeyError('XDG_SESSION_TYPE')
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/pywinctl/__init__.py", line 27, in <module>
    from ._main import (Re, Window, checkPermissions, getActiveWindow,
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/pywinctl/_main.py", line 14, in <module>
    from pymonctl import findMonitorsAtPoint, getAllMonitors, getAllMonitorsDict
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/pymonctl/__init__.py", line 22, in <module>
    from ._main import (getAllMonitors, getAllMonitorsDict, getMonitorsCount, getPrimary,
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/pymonctl/_main.py", line 916, in <module>
    from ._pymonctl_linux import (_getAllMonitors, _getAllMonitorsDict, _getMonitorsCount, _getPrimary,
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/pymonctl/_pymonctl_linux.py", line 22, in <module>
    from ewmhlib import defaultEwmhRoot, getProperty, getPropertyValue, getRoots, getRootsInfo, Props
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/ewmhlib/__init__.py", line 23, in <module>
    from ._main import (displaysCount, getDisplays, getDisplaysInfo, getRoots, getRootsInfo,
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/ewmhlib/_main.py", line 4, in <module>
    from ._ewmhlib import (displaysCount, getDisplays, getDisplaysInfo, getRoots, getRootsInfo,
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/ewmhlib/_ewmhlib.py", line 60, in <module>
    displaysCount: int = len(getDisplays())
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/ewmhlib/_ewmhlib.py", line 45, in getDisplays
    if not _displays and os.environ['XDG_SESSION_TYPE'].lower() != "wayland":
  File "/home/tim/.julia/conda/3/lib/python3.10/os.py", line 679, in __getitem__
    raise KeyError(key) from None

Stacktrace:
  [1] pyimport(name::String)
    @ PyCall ~/.julia/packages/PyCall/1gn3u/src/PyCall.jl:558
  [2] pyimport_pip(modulename::String; dependency::String, channel::String)
    @ JustSayIt ~/.julia/packages/JustSayIt/w35dO/src/shared.jl:449
  [3] pyimport_pip
    @ JustSayIt ~/.julia/packages/JustSayIt/w35dO/src/shared.jl:440 [inlined]
  [4] __init__()
    @ JustSayIt ~/.julia/packages/JustSayIt/w35dO/src/shared.jl:25
  [5] run_module_init(mod::Module, i::Int64)
    @ Base ./loading.jl:1128
  [6] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1116
  [7] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1061
  [8] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
    @ Base ./loading.jl:1575
  [9] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1932
 [10] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1806
 [11] #invoke_in_world#3
    @ Base ./essentials.jl:921 [inlined]
 [12] invoke_in_world
    @ Base ./essentials.jl:918 [inlined]
 [13] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1797
 [14] macro expansion
    @ Base ./loading.jl:1784 [inlined]
 [15] macro expansion
    @ Base ./lock.jl:267 [inlined]
 [16] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1747
 [17] #invoke_in_world#3
    @ Base ./essentials.jl:921 [inlined]
 [18] invoke_in_world
    @ Base ./essentials.jl:918 [inlined]
 [19] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1740
during initialization of module JustSayIt

caused by: PyError (PyImport_ImportModule) <class 'KeyError'>
KeyError('XDG_SESSION_TYPE')
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/pywinctl/__init__.py", line 27, in <module>
    from ._main import (Re, Window, checkPermissions, getActiveWindow,
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/pywinctl/_main.py", line 14, in <module>
    from pymonctl import findMonitorsAtPoint, getAllMonitors, getAllMonitorsDict
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/pymonctl/__init__.py", line 22, in <module>
    from ._main import (getAllMonitors, getAllMonitorsDict, getMonitorsCount, getPrimary,
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/pymonctl/_main.py", line 916, in <module>
    from ._pymonctl_linux import (_getAllMonitors, _getAllMonitorsDict, _getMonitorsCount, _getPrimary,
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/pymonctl/_pymonctl_linux.py", line 22, in <module>
    from ewmhlib import defaultEwmhRoot, getProperty, getPropertyValue, getRoots, getRootsInfo, Props
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/ewmhlib/__init__.py", line 23, in <module>
    from ._main import (displaysCount, getDisplays, getDisplaysInfo, getRoots, getRootsInfo,
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/ewmhlib/_main.py", line 4, in <module>
    from ._ewmhlib import (displaysCount, getDisplays, getDisplaysInfo, getRoots, getRootsInfo,
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/ewmhlib/_ewmhlib.py", line 60, in <module>
    displaysCount: int = len(getDisplays())
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/ewmhlib/_ewmhlib.py", line 45, in getDisplays
    if not _displays and os.environ['XDG_SESSION_TYPE'].lower() != "wayland":
  File "/home/tim/.julia/conda/3/lib/python3.10/os.py", line 679, in __getitem__
    raise KeyError(key) from None

Stacktrace:
  [1] pyimport(name::String)
    @ PyCall ~/.julia/packages/PyCall/1gn3u/src/PyCall.jl:558
  [2] pyimport_pip(modulename::String; dependency::String, channel::String)
    @ JustSayIt ~/.julia/packages/JustSayIt/w35dO/src/shared.jl:443
  [3] pyimport_pip
    @ JustSayIt ~/.julia/packages/JustSayIt/w35dO/src/shared.jl:440 [inlined]
  [4] __init__()
    @ JustSayIt ~/.julia/packages/JustSayIt/w35dO/src/shared.jl:25
  [5] run_module_init(mod::Module, i::Int64)
    @ Base ./loading.jl:1128
  [6] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1116
  [7] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1061
  [8] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
    @ Base ./loading.jl:1575
  [9] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1932
 [10] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1806
 [11] #invoke_in_world#3
    @ Base ./essentials.jl:921 [inlined]
 [12] invoke_in_world
    @ Base ./essentials.jl:918 [inlined]
 [13] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1797
 [14] macro expansion
    @ Base ./loading.jl:1784 [inlined]
 [15] macro expansion
    @ Base ./lock.jl:267 [inlined]
 [16] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1747
 [17] #invoke_in_world#3
    @ Base ./essentials.jl:921 [inlined]
 [18] invoke_in_world
    @ Base ./essentials.jl:918 [inlined]
 [19] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1740

The error with ENV was just to show that nothing is defined for ENV["PYTHON"]. Also:

julia> versioninfo()
Julia Version 1.10.0-rc3
Commit ed79752b939 (2023-12-18 09:57 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × 12th Gen Intel(R) Core(TM) i7-1260P
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, alderlake)
  Threads: 1 on 16 virtual cores
Environment:
  JULIA_IMAGE_THREADS = 4

This is on WSL.

@timholy
Copy link
Author

timholy commented Dec 26, 2023

Turns out I can work around this, but then get a different error:

julia> ENV["XDG_SESSION_TYPE"] = "x11"
"x11"

julia> using JustSayIt

julia> start()
[ Info: JustSayIt: I am initializing...
[ Info: No accurate large model for the type language (English (United States)) found in its default location (/home/tim/.local/share/JustSayIt/models/vosk-model-en-us-daanzu-20200905): download (optional) accurate large model (vosk-model-en-us-daanzu-20200905.zip) from 'https://alphacephei.com/vosk/models' (~1-2 GB)?
Type "yes" or "no":
no
┌ Warning: Not downloading large accurate model for typing the default language (English (United States)): falling back to default model for typing.
└ @ JustSayIt ~/.julia/packages/JustSayIt/w35dO/src/init_jsi.jl:182
ERROR: PyError ($(Expr(:escape, :(ccall(#= /home/tim/.julia/packages/PyCall/1gn3u/src/pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'sounddevice.PortAudioError'>
PortAudioError('Error querying device -1')
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/sounddevice.py", line 1192, in __init__
    _StreamBase.__init__(self, kind='input', wrap_callback='buffer',
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/sounddevice.py", line 817, in __init__
    _get_stream_parameters(kind, device, channels, dtype, latency,
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/sounddevice.py", line 2660, in _get_stream_parameters
    info = query_devices(device)
  File "/home/tim/.julia/conda/3/lib/python3.10/site-packages/sounddevice.py", line 569, in query_devices
    raise PortAudioError(f'Error querying device {device}')

Stacktrace:
  [1] pyerr_check
    @ PyCall ~/.julia/packages/PyCall/1gn3u/src/exception.jl:75 [inlined]
  [2] pyerr_check
    @ PyCall ~/.julia/packages/PyCall/1gn3u/src/exception.jl:79 [inlined]
  [3] _handle_error(msg::String)
    @ PyCall ~/.julia/packages/PyCall/1gn3u/src/exception.jl:96
  [4] macro expansion
    @ ~/.julia/packages/PyCall/1gn3u/src/exception.jl:110 [inlined]
  [5] #107
    @ ~/.julia/packages/PyCall/1gn3u/src/pyfncall.jl:43 [inlined]
  [6] disable_sigint
    @ ./c.jl:473 [inlined]
  [7] __pycall!
    @ ~/.julia/packages/PyCall/1gn3u/src/pyfncall.jl:42 [inlined]
  [8] _pycall!(ret::PyCall.PyObject, o::PyCall.PyObject, args::Tuple{}, nargs::Int64, kw::PyCall.PyObject)
    @ PyCall ~/.julia/packages/PyCall/1gn3u/src/pyfncall.jl:29
  [9] _pycall!(ret::PyCall.PyObject, o::PyCall.PyObject, args::Tuple{}, kwargs::@Kwargs{})
    @ PyCall ~/.julia/packages/PyCall/1gn3u/src/pyfncall.jl:11
 [10] #_#114
    @ PyCall ~/.julia/packages/PyCall/1gn3u/src/pyfncall.jl:86 [inlined]
 [11] start_recording(; id::String, audio_input_cmd::Nothing)
    @ JustSayIt ~/.julia/packages/JustSayIt/w35dO/src/recorder.jl:68
 [12] start_recording
    @ ~/.julia/packages/JustSayIt/w35dO/src/recorder.jl:63 [inlined]
 [13] start(; default_language::String, type_languages::String, commands::Nothing, subset::Nothing, max_speed_subset::Nothing, modeldirs::Nothing, noises::Dict{…}, audio_input_cmd::Nothing)
    @ JustSayIt ~/.julia/packages/JustSayIt/w35dO/src/start.jl:159
 [14] start()
    @ JustSayIt ~/.julia/packages/JustSayIt/w35dO/src/start.jl:132
 [15] top-level scope
    @ REPL[3]:1
Some type information was truncated. Use `show(err)` to see complete types.

I note that the errors are all in the Python libraries, not your Julia code.

@omlins
Copy link
Owner

omlins commented Jan 17, 2024

Thank you for your interest! I'm sorry that you ran into these errors, which as you noted are in the dependencies. It looks like for some reason it cannot detect your microphone (PortAudioError('Error querying device -1')). Are you using some non-standard microphone or driver?

@timholy
Copy link
Author

timholy commented Jan 17, 2024

Possibly due to WSL? Today I tried it on Windows, and got this:

julia> cd("C:\\Users\\timho\\Downloads\\VoiceAssist")

(@v1.10) pkg> activate .
  Activating project at `C:\Users\timho\Downloads\VoiceAssist`

julia> using JustSayIt
[ Info: Running `conda config --set pip_interop_enabled true --file 'C:\Users\timho\.julia\conda\3\condarc-julia.yml'` in root environment
ERROR: InitError: IOError: could not spawn setenv(`'C:\Users\timho\.julia\conda\3\Scripts\conda.exe' config --set pip_interop_enabled true --file 'C:\Users\timho\.julia\conda\3\condarc-julia.yml'`,["WINDIR=C:\\WINDOWS", "PATH=C:\\Users\\timho\\.julia\\conda\\3\\Library\\bin;C:\\Users\\timho\\.julia\\conda\\3\\lib\\site-packages\\vosk;C:\\Users\\timho\\.julia\\conda\\3\\Library\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Docker\\Docker\\resources\\bin;C:\\Users\\timho\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\timho\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Users\\timho\\AppData\\Local\\Pandoc\\;C:\\texlive\\2023\\bin\\windows", "USERDOMAIN_ROAMINGPROFILE=DIVA", "ZES_ENABLE_SYSMAN=1", "JSI_USE_PYTHON=1", "LOCALAPPDATA=C:\\Users\\timho\\AppData\\Local", "HOMEPATH=\\Users\\timho", "PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 154 Stepping 3, GenuineIntel", "NUMBER_OF_PROCESSORS=16", "PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC", "SYSTEMROOT=C:\\WINDOWS", "APPDATA=C:\\Users\\timho\\AppData\\Roaming", "PSMODULEPATH=C:\\Program Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules", "COMMONPROGRAMW6432=C:\\Program Files\\Common Files", "PROGRAMDATA=C:\\ProgramData", "PUBLIC=C:\\Users\\Public", "USERDOMAIN=DIVA", "OS=Windows_NT", "PROCESSOR_REVISION=9a03", "TMP=C:\\Users\\timho\\AppData\\Local\\Temp", "COMMONPROGRAMFILES(X86)=C:\\Program Files (x86)\\Common Files", "COMSPEC=C:\\WINDOWS\\system32\\cmd.exe", "OPENBLAS_DEFAULT_NUM_THREADS=1", "NSPR_NATIVE_THREADS_ONLY=1", "ALLUSERSPROFILE=C:\\ProgramData", "COMMONPROGRAMFILES=C:\\Program Files\\Common Files", "COMPUTERNAME=DIVA", "JULIA_NUM_THREADS=4", "ONEDRIVE=C:\\Users\\timho\\OneDrive", "USERNAME=timho", "PROGRAMFILES(X86)=C:\\Program Files (x86)", "PROGRAMFILES=C:\\Program Files", "CONDARC=C:\\Users\\timho\\.julia\\conda\\3\\condarc-julia.yml", "LOGONSERVER=\\\\DIVA", "ONEDRIVECONSUMER=C:\\Users\\timho\\OneDrive", "USERPROFILE=C:\\Users\\timho", "DRIVERDATA=C:\\Windows\\System32\\Drivers\\DriverData", "CONDA_PREFIX=C:\\Users\\timho\\.julia\\conda\\3", "PROCESSOR_LEVEL=6", "SYSTEMDRIVE=C:", "=C:=C:\\Users\\timho\\Downloads\\VoiceAssist", "PROGRAMW6432=C:\\Program Files", "TEMP=C:\\Users\\timho\\AppData\\Local\\Temp", "HOMEDRIVE=C:", "OPENBLAS_MAIN_FREE=1", "PROCESSOR_ARCHITECTURE=AMD64", "PYTHONIOENCODING=UTF-8"]): operation not supported on socket (ENOTSUP)
Stacktrace:
  [1] _spawn_primitive(file::String, cmd::Cmd, stdio::Vector{Union{RawFD, Base.Libc.WindowsRawSocket, IO}})
    @ Base .\process.jl:128
  [2] #784
    @ Base .\process.jl:139 [inlined]
  [3] setup_stdios(f::Base.var"#784#785"{Cmd}, stdios::Vector{Union{RawFD, Base.Libc.WindowsRawSocket, IO}})
    @ Base .\process.jl:223
  [4] _spawn
    @ Base .\process.jl:138 [inlined]
  [5] run(::Cmd; wait::Bool)
    @ Base .\process.jl:479
  [6] run
    @ Base .\process.jl:477 [inlined]
  [7] runconda(args::Cmd, env::String)
    @ Conda C:\Users\timho\.julia\packages\Conda\sDjAP\src\Conda.jl:182
  [8] pip_interop (repeats 2 times)
    @ Conda C:\Users\timho\.julia\packages\Conda\sDjAP\src\Conda.jl:622 [inlined]
  [9] pyimport_pip(modulename::String; dependency::String, channel::String)
    @ JustSayIt C:\Users\timho\.julia\packages\JustSayIt\w35dO\src\shared.jl:446
 [10] pyimport_pip
    @ JustSayIt C:\Users\timho\.julia\packages\JustSayIt\w35dO\src\shared.jl:440 [inlined]
 [11] __init__()
    @ JustSayIt C:\Users\timho\.julia\packages\JustSayIt\w35dO\src\shared.jl:25
 [12] run_module_init(mod::Module, i::Int64)
    @ Base .\loading.jl:1128
 [13] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base .\loading.jl:1116
 [14] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
    @ Base .\loading.jl:1061
 [15] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
    @ Base .\loading.jl:1575
 [16] _require(pkg::Base.PkgId, env::String)
    @ Base .\loading.jl:1932
 [17] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base .\loading.jl:1806
 [18] #invoke_in_world#3
    @ Base .\essentials.jl:921 [inlined]
 [19] invoke_in_world
    @ Base .\essentials.jl:918 [inlined]
 [20] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base .\loading.jl:1797
 [21] macro expansion
    @ Base .\loading.jl:1784 [inlined]
 [22] macro expansion
    @ Base .\lock.jl:267 [inlined]
 [23] __require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1747
 [24] #invoke_in_world#3
    @ Base .\essentials.jl:921 [inlined]
 [25] invoke_in_world
    @ Base .\essentials.jl:918 [inlined]
 [26] require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1740
during initialization of module JustSayIt

caused by: PyError (PyImport_ImportModule

The Python package pywinctl could not be imported by pyimport. Usually this means
that you did not install pywinctl in the Python version being used by PyCall.

PyCall is currently configured to use the Julia-specific Python distribution
installed by the Conda.jl package.  To install the pywinctl module, you can
use `pyimport_conda("pywinctl", PKG)`, where PKG is the Anaconda
package that contains the module pywinctl, or alternatively you can use the
Conda package directly (via `using Conda` followed by `Conda.add` etcetera).

Alternatively, if you want to use a different Python distribution on your
system, such as a system-wide Python (as opposed to the Julia-specific Python),
you can re-configure PyCall with that Python.   As explained in the PyCall
documentation, set ENV["PYTHON"] to the path/name of the python executable
you want to use, run Pkg.build("PyCall"), and re-launch Julia.

) <class 'ModuleNotFoundError'>
ModuleNotFoundError("No module named 'pywinctl'")

Stacktrace:
  [1] pyimport(name::String)
    @ PyCall C:\Users\timho\.julia\packages\PyCall\1gn3u\src\PyCall.jl:558
  [2] pyimport_pip(modulename::String; dependency::String, channel::String)
    @ JustSayIt C:\Users\timho\.julia\packages\JustSayIt\w35dO\src\shared.jl:443
  [3] pyimport_pip
    @ JustSayIt C:\Users\timho\.julia\packages\JustSayIt\w35dO\src\shared.jl:440 [inlined]
  [4] __init__()
    @ JustSayIt C:\Users\timho\.julia\packages\JustSayIt\w35dO\src\shared.jl:25
  [5] run_module_init(mod::Module, i::Int64)
    @ Base .\loading.jl:1128
  [6] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base .\loading.jl:1116
  [7] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
    @ Base .\loading.jl:1061
  [8] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
    @ Base .\loading.jl:1575
  [9] _require(pkg::Base.PkgId, env::String)
    @ Base .\loading.jl:1932
 [10] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base .\loading.jl:1806
 [11] #invoke_in_world#3
    @ Base .\essentials.jl:921 [inlined]
 [12] invoke_in_world
    @ Base .\essentials.jl:918 [inlined]
 [13] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base .\loading.jl:1797
 [14] macro expansion
    @ Base .\loading.jl:1784 [inlined]
 [15] macro expansion
    @ Base .\lock.jl:267 [inlined]
 [16] __require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1747
 [17] #invoke_in_world#3
    @ Base .\essentials.jl:921 [inlined]
 [18] invoke_in_world
    @ Base .\essentials.jl:918 [inlined]
 [19] require(into::Module, mod::Symbol)
    @ Base .\loading.jl:1740

julia> pyimport_conda("pywinctl", "pywinctl")
ERROR: UndefVarError: `pyimport_conda` not defined
Stacktrace:
 [1] top-level scope
   @ REPL[4]:1

I got the same error from Conda.add("pywinctl"). (Julia packages are much easier to install than Python packages!!)

@omlins
Copy link
Owner

omlins commented Jan 19, 2024

(Julia packages are much easier to install than Python packages!!)
That's definitely very true!

That's very unfortunate that the same package causes also in windows a problem. pyimport_conda is a function of the package PyCall if you want to try the suggestion in the error message...

@omlins
Copy link
Owner

omlins commented Jan 19, 2024

Concerning the error of the python package sounddevice on Linux: maybe the installation of the dependency portaudio, which is not a python dependency, was not successful. It should have been triggered here:
https://github.com/omlins/JustSayIt.jl/blob/main/src/shared.jl#L20

... and installed with conda as you can see here:
https://github.com/omlins/JustSayIt.jl/blob/main/src/shared.jl#L440-L464

Maybe you can try to do these steps manually and see if this brings you further?

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