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

DLL loading fails when using pyenv and poetry on Windows #589

Closed
daara-s opened this issue Oct 16, 2024 · 1 comment · Fixed by #590
Closed

DLL loading fails when using pyenv and poetry on Windows #589

daara-s opened this issue Oct 16, 2024 · 1 comment · Fixed by #590

Comments

@daara-s
Copy link
Contributor

daara-s commented Oct 16, 2024

When using pyenv for python versions, and poetry for virtual environments, the following bit of lib loading code for treelite breaks with the error:

ImportError while loading conftest 'C:\Users\daarashaw\windows-dev\my_repo\tests\conftest.py'.
...
..\..\AppData\Local\pypoetry\Cache\virtualenvs\my-repo-py3.10\lib\site-packages\tl2cgen\__init__.py:6: in <module>
    from .core import _dump_compiler_ast, _py_version, annotate_branch, generate_c_code
..\..\AppData\Local\pypoetry\Cache\virtualenvs\my-repo-py3.10\lib\site-packages\tl2cgen\core.py:8: in <module>
    import treelite
..\..\AppData\Local\pypoetry\Cache\virtualenvs\my-repo-py3.10\lib\site-packages\treelite\__init__.py:5: in <module>
    from . import frontend, gtil, model_builder, sklearn
..\..\AppData\Local\pypoetry\Cache\virtualenvs\my-repo-py3.10\lib\site-packages\treelite\frontend.py:10: in <module>
    from . import compat
..\..\AppData\Local\pypoetry\Cache\virtualenvs\my-repo-py3.10\lib\site-packages\treelite\compat.py:9: in <module>
    from .core import _LIB, TreeliteError, _check_call
..\..\AppData\Local\pypoetry\Cache\virtualenvs\my-repo-py3.10\lib\site-packages\treelite\core.py:58: in <module>
    _LIB = _load_lib()
..\..\AppData\Local\pypoetry\Cache\virtualenvs\my-repo-py3.10\lib\site-packages\treelite\core.py:36: in _load_lib
    os.add_dll_directory(
..\..\.pyenv\pyenv-win\versions\3.10.11\lib\os.py:1118: in add_dll_directory
    cookie = nt._add_dll_directory(path)
E   FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\daarashaw\\.pyenv\\pyenv-win\\versions\\3.10.11\\Library\\bin'

poetry env info

Virtualenv
Python:         3.10.11
Implementation: CPython
Path:           C:\Users\daarashaw\AppData\Local\pypoetry\Cache\virtualenvs\my-repo-py3.10
Executable:     C:\Users\daarashaw\AppData\Local\pypoetry\Cache\virtualenvs\my-repo-py3.10\Scripts\python.exe
Valid:          True

Base
Platform:   win32
OS:         nt
Python:     3.10.11
Path:       C:\Users\daarashaw\.pyenv\pyenv-win\versions\3.10.11
Executable: C:\Users\daarashaw\.pyenv\pyenv-win\versions\3.10.11\python.exe

In here, it doesn't check whether the folder exists, causing it to break.

I've been able to manually solve it my making the Library/bin directory under my base virtualenv.


What's the purpose of this dll location check, is it for a specific python install method (eg via conda?)

I can make a quick PR fix to solve it later today. Should just need checking whether the folder exists before trying to add a dll from it.

@hcho3
Copy link
Collaborator

hcho3 commented Oct 16, 2024

Yes, feel free to submit a pull request.

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

Successfully merging a pull request may close this issue.

2 participants