Open wenjian-zhou opened 2 months ago
Common reasons on windows is installing a 32b version in one environment, then trying to import in a 64b version of Python, so recommend to check that first.
If any of the listed libraries (libcppyy_backend.cp311-win_amd64.pyd
etc.) exist, try loading it with ctypes.CDLL
(using the full path). Typically, that gives a clearer error message.
Common reasons on windows is installing a 32b version in one environment, then trying to import in a 64b version of Python, so recommend to check that first.
If any of the listed libraries (
libcppyy_backend.cp311-win_amd64.pyd
etc.) exist, try loading it withctypes.CDLL
(using the full path). Typically, that gives a clearer error message.Common reasons on windows is installing a 32b version in one environment, then trying to import in a 64b version of Python, so recommend to check that first.
If any of the listed libraries (
libcppyy_backend.cp311-win_amd64.pyd
etc.) exist, try loading it withctypes.CDLL
(using the full path). Typically, that gives a clearer error message.
I just tried to modify the _load_helper function to load the libcppyy_backend.dll:
def _load_helper(bkname):
errors = set()
pkgpath = "C:\\Users\\Pengpei\\AppData\\Local\\Programs\\Python\\Python39\\Lib\\site-packages\\cppyy_backend"
dllpath = os.path.join(pkgpath, 'lib', bkname)
print(dllpath)
print(ctypes.CDLL(dllpath))
exit()
And it printed the correct .dll path but just could not link it:
File "C:\ExperimentEnvs\turay-main\1.py", line 1, in <module>
import cppyy
File "C:\Users\Pengpei\AppData\Local\Programs\Python\Python39\lib\site-packages\cppyy\__init__.py", line 81, in <module>
from ._cpython_cppyy import *
File "C:\Users\Pengpei\AppData\Local\Programs\Python\Python39\lib\site-packages\cppyy\_cpython_cppyy.py", line 21, in <module>
c = loader.load_cpp_backend()
File "C:\Users\Pengpei\AppData\Local\Programs\Python\Python39\lib\site-packages\cppyy_backend\loader.py", line 98, in load_cpp_backend
c, err2 = _load_helper(name)
File "C:\Users\Pengpei\AppData\Local\Programs\Python\Python39\lib\site-packages\cppyy_backend\loader.py", line 36, in _load_helper
print(ctypes.CDLL(dllpath))
File "C:\Users\Pengpei\AppData\Local\Programs\Python\Python39\lib\ctypes\__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\Pengpei\AppData\Local\Programs\Python\Python39\Lib\site-packages\cppyy_backend\lib\libcppyy_backend.dll' (or one of its dependencies). Try using the full path with constructor syntax.
I am sure that path is correct but I have no idea what's going on here (I mean why it's there and the path is correct but ctypes couldn't find it). And I did find that there's a .pyd file named libcppyy.cp39-win_amd64.pyd (instead of libcppyy_backend.pyd) under my \Python39\Lib\site-packages. Is this .pyd file the one we need?
There're some other errors but I am not sure whether it's due to the lack of dll and pyd file:
(Re-)building pre-compiled headers (options: -O2 -march=native); this may take a minute ...
In file included from input_line_3:2:
In file included from C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\string:10:
In file included from C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\xstring:16:
In file included from C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\xpolymorphic_allocator.h:10:
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\tuple:957:9: error: static_assert failed "get<T>(tuple<Types...>&) requires T to occur exactly once in Types. (N4971 [tuple.elem]/5)"
static_assert(false, "get<T>(tuple<Types...>&) "
^ ~~~~~
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\tuple:969:9: error: static_assert failed "get<T>(const tuple<Types...>&) requires T to occur exactly once in Types. (N4971 [tuple.elem]/5)"
static_assert(false, "get<T>(const tuple<Types...>&) "
^ ~~~~~
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\tuple:981:9: error: static_assert failed "get<T>(tuple<Types...>&&) requires T to occur exactly once in Types. (N4971 [tuple.elem]/5)"
static_assert(false, "get<T>(tuple<Types...>&&) "
^ ~~~~~
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\tuple:993:9: error: static_assert failed "get<T>(const tuple<Types...>&&) requires T to occur exactly once in Types. (N4971 [tuple.elem]/5)"
static_assert(false, "get<T>(const tuple<Types...>&&) "
^ ~~~~~
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:94:14: error: redefinition of 'wcscat_s'
errno_t, wcscat_s,
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:114:14: error: redefinition of 'wcscpy_s'
errno_t, wcscpy_s,
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:161:38: error: redefinition of 'wcsnlen_s'
static __inline size_t __CRTDECL wcsnlen_s(
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:172:14: error: redefinition of 'wcsncat_s'
errno_t, wcsncat_s,
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:194:14: error: redefinition of 'wcsncpy_s'
errno_t, wcsncpy_s,
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:239:40: error: redefinition of '_wcstok'
static __inline wchar_t* __CRTDECL _wcstok(
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:253:35: error: redefinition of 'wcstok'
inline wchar_t* __CRTDECL wcstok(
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:280:14: error: redefinition of '_wcserror_s'
errno_t, _wcserror_s,
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:299:14: error: redefinition of '__wcserror_s'
errno_t, __wcserror_s,
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:336:14: error: redefinition of '_wcsnset_s'
errno_t, _wcsnset_s,
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:361:14: error: redefinition of '_wcsset_s'
errno_t, _wcsset_s,
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:379:14: error: redefinition of '_wcslwr_s'
errno_t, _wcslwr_s,
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:396:14: error: redefinition of '_wcslwr_s_l'
errno_t, _wcslwr_s_l,
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:415:14: error: redefinition of '_wcsupr_s'
errno_t, _wcsupr_s,
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:432:14: error: redefinition of '_wcsupr_s_l'
errno_t, _wcsupr_s_l,
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:529:31: error: redefinition of 'wcschr'
inline wchar_t* __CRTDECL wcschr(_In_z_ wchar_t* _String, wchar_t _C)
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:535:31: error: redefinition of 'wcspbrk'
inline wchar_t* __CRTDECL wcspbrk(_In_z_ wchar_t* _String, _In_z_ wchar_t const* _Control)
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:541:31: error: redefinition of 'wcsrchr'
inline wchar_t* __CRTDECL wcsrchr(_In_z_ wchar_t* _String, _In_ wchar_t _C)
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
In file included from input_line_4:4:
In file included from C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\string.h:14:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h:548:31: error: redefinition of 'wcsstr'
inline wchar_t* __CRTDECL wcsstr(_In_z_ wchar_t* _String, _In_z_ wchar_t const*_SubStr)
^
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_wstring.h: note: previous definition is here
fatal error: too many errors emitted, stopping now [-ferror-limit=]
Error: Error loading the default header files.
C:\Users\Pengpei\AppData\Local\Programs\Python\Python39\lib\site-packages\cppyy_backend\loader.py:139: UserWarning: No precompiled header available (failed to build); this may impact performance.
warnings.warn('No precompiled header available (%s); this may impact performance.' % msg)
In file included from input_line_1:1:
In file included from C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\new:10:
In file included from C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\exception:12:
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\type_traits:1390:5: error: expected a type
_Copy_cv_impl<_From>::template _Apply<_To>;
^
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\type_traits:1390:27: error: expected ';' after alias declaration
_Copy_cv_impl<_From>::template _Apply<_To>;
^
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\type_traits:1395:20: error: no template named '_Copy_cv'
using _Apply = _Copy_cv<_Ty1, _Ty2>;
^
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\type_traits:1400:43: error: use of undeclared identifier '_Copy_cv'
using _Apply = add_lvalue_reference_t<_Copy_cv<_Ty1, _Ty2>>;
^
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\type_traits:1405:43: error: use of undeclared identifier '_Copy_cv'
using _Apply = add_rvalue_reference_t<_Copy_cv<_Ty1, _Ty2>>;
^
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\type_traits:1416:28: error: missing 'typename' prior to dependent type name 'common_reference<_Types...>::type'
using common_reference_t = common_reference<_Types...>::type;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\type_traits:1444:31: error: missing 'typename' prior to dependent type name 'basic_common_reference<typename remove_cv<typename
remove_reference<type-parameter-0-0>::type>::type, typename remove_cv<typename
remove_reference<type-parameter-0-1>::type>::type, _Add_qualifiers<_Ty1>::template _Apply,
_Add_qualifiers<_Ty2>::template _Apply>::type'
using _Basic_specialization = basic_common_reference<remove_cvref_t<_Ty1>, remove_cvref_t<_Ty2>,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\type_traits:1463:67: error: expected expression
requires is_lvalue_reference_v<_Cond_res<_Copy_cv<_Ty1, _Ty2>&, _Copy_cv<_Ty2, _Ty1>&>>
^
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\type_traits:1463:46: error: use of undeclared identifier '_Copy_cv'
requires is_lvalue_reference_v<_Cond_res<_Copy_cv<_Ty1, _Ty2>&, _Copy_cv<_Ty2, _Ty1>&>>
^
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\type_traits:1470:34: error: no template named '_LL_common_ref'
requires requires { typename _LL_common_ref<_Ty1, _Ty2>; }
^
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\type_traits:1476:39: error: use of undeclared identifier '_LL_common_ref'
requires is_convertible_v<_Ty1&&, _LL_common_ref<const _Ty1, _Ty2>>
^
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\type_traits:1482:39: error: use of undeclared identifier '_LL_common_ref'
requires is_convertible_v<_Ty2&&, _LL_common_ref<const _Ty2, _Ty1>>
^
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\type_traits:1488:43: error: use of undeclared identifier '_LL_common_ref'
using _RR_common_ref = remove_reference_t<_LL_common_ref<_Ty1, _Ty2>>&&;
^
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\type_traits:1491:39: error: use of undeclared identifier '_RR_common_ref'
requires is_convertible_v<_Ty1&&, _RR_common_ref<_Ty1, _Ty2>>
^
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\type_traits:1498:27: error: missing 'typename' prior to dependent type name '_Common_reference2AX<_Ty1, _Ty2>::type'
using _Common_ref_2AX_t = _Common_reference2AX<_Ty1, _Ty2>::type;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\type_traits:1523:25: error: missing 'typename' prior to dependent type name 'type_identity<_Ty>::type'
using type_identity_t = type_identity<_Ty>::type;
^~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\\include\type_traits:2087:28: error: missing 'typename' prior to dependent type name 'unwrap_reference<_Ty>::type'
using unwrap_reference_t = unwrap_reference<_Ty>::type;
^~~~~~~~~~~~~~~~~~~~~~~~~~~
Traceback (most recent call last):
File "C:\ExperimentEnvs\turay-main\1.py", line 1, in <module>
import cppyy
File "C:\Users\Pengpei\AppData\Local\Programs\Python\Python39\lib\site-packages\cppyy\__init__.py", line 81, in <module>
from ._cpython_cppyy import *
File "C:\Users\Pengpei\AppData\Local\Programs\Python\Python39\lib\site-packages\cppyy\_cpython_cppyy.py", line 21, in <module>
c = loader.load_cpp_backend()
File "C:\Users\Pengpei\AppData\Local\Programs\Python\Python39\lib\site-packages\cppyy_backend\loader.py", line 92, in load_cpp_backend
raise RuntimeError("could not load cppyy_backend library, details:\n%s" %
RuntimeError: could not load cppyy_backend library, details:
Could not find module 'libcppyy_backend.pyd' (or one of its dependencies). Try using the full path with constructor syntax.
Could not find module 'libcppyy_backend.dll' (or one of its dependencies). Try using the full path with constructor syntax.
Could not find module 'C:\Users\Pengpei\AppData\Local\Programs\Python\Python39\lib\site-packages\cppyy_backend\lib\libcppyy_backend.pyd' (or one of its dependencies). Try using the full path with constructor syntax.
[WinError 1114] A dynamic link library (DLL) initialization routine failed
I run into this error and don't have a clue how to fix it.
Details:
RuntimeError: could not load cppyy_backend library, details: Could not find module 'libcppyy_backend.dll' (or one of its dependencies). Try using the full path with constructor syntax. [WinError 1114] A dynamic link library (DLL) initialization routine failed Could not find module 'libcppyy_backend.cp311-win_amd64.pyd' (or one of its dependencies). Try using the full path with constructor syntax. Could not find module 'D:\miniconda3\envs\turay\Lib\site-packages\cppyy_backend\lib\libcppyy_backend.cp311-win_amd64.pyd' (or one of its dependencies). Try using the full path with constructor syntax.
I found
libcppyy_backend.dll
incppyy_backend\lib
but I don't find thelibcppyy_backend.cp311-win_amd64.pyd