microsoft / qlib

Qlib is an AI-oriented quantitative investment platform that aims to realize the potential, empower research, and create value using AI technologies in quantitative investment, from exploring ideas to implementing productions. Qlib supports diverse machine learning modeling paradigms. including supervised learning, market dynamics modeling, and RL.
https://qlib.readthedocs.io/en/latest/
MIT License
14.54k stars 2.53k forks source link

Error with installing pyqlib from source using "pip install ." #1769

Open VenerableDeity opened 3 months ago

VenerableDeity commented 3 months ago

I use the Windows system and have installed Python 3.8.19. I encountered a problem while installing pyqlib. How can I resolve this?

Building wheels for collected packages: pyqlib Building wheel for pyqlib (pyproject.toml) ... error error: subprocess-exited-with-error

× Building wheel for pyqlib (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [202 lines of output] running bdist_wheel running build running build_py running egg_info writing pyqlib.egg-info\PKG-INFO writing dependency_links to pyqlib.egg-info\dependency_links.txt writing entry points to pyqlib.egg-info\entry_points.txt writing requirements to pyqlib.egg-info\requires.txt writing top-level names to pyqlib.egg-info\top_level.txt reading manifest file 'pyqlib.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching 'qlib\VERSION.txt' adding license file 'LICENSE' writing manifest file 'pyqlib.egg-info\SOURCES.txt' running build_ext Compiling qlib/data/libs/rolling.pyx because it depends on C:\Users\xing\AppData\Local\Temp\pip-build-env-4muktctc\overlay\Lib\site-packages\Cython\Includes\libcpp\deque.pxd. [1/1] Cythonizing qlib/data/_libs/rolling.pyx building 'qlib.data.libs.rolling' extension "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\xing\AppData\Local\Temp\pip-build-env-4muktctc\overlay\Lib\site-packages\numpy\core\include -ID:\Program_Files\anaconda3\envs\qlib\include -ID:\Program_Files\anaconda3\envs\qlib\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\VS\include" "-ID:\Windows Kits\10\include\10.0.22000.0\ucrt" "-ID:\Windows Kits\10\include\10.0.22000.0\um" "-ID:\Windows Kits\10\include\10.0.22000.0\shared" "-ID:\Windows Kits\10\include\10.0.22000.0\winrt" "-ID:\Windows Kits\10\include\10.0.22000.0\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-ID:\Windows Kits\10\include\10.0.22000.0\ucrt" "-ID:\Windows Kits\10\include\10.0.22000.0\shared" "-ID:\Windows Kits\10\include\10.0.22000.0\um" "-ID:\Windows Kits\10\include\10.0.22000.0\winrt" "-ID:\Windows Kits\10\include\10.0.22000.0\cppwinrt" /EHsc /Tpqlib/data/_libs/rolling.cpp /Fobuild\temp.win32-cpython-38\Release\qlib/data/libs/rolling.obj rolling.cpp C:\Users\xing\AppData\Local\Temp\pip-build-env-4muktctc\overlay\Lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(14) : Warning Msg: Using deprecated NumPy API, disable it with #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\link.exe" /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:D:\Program_Files\anaconda3\envs\qlib\libs /LIBPATH:D:\Program_Files\anaconda3\envs\qlib /LIBPATH:D:\Program_Files\anaconda3\envs\qlib\PCbuild\win32 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\ATLMFC\lib\x86" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\lib\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x86" "/LIBPATH:D:\Windows Kits\10\lib\10.0.22000.0\ucrt\x86" "/LIBPATH:D:\Windows Kits\10\lib\10.0.22000.0\um\x86" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\ATLMFC\lib\x86" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\lib\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x86" "/LIBPATH:D:\Windows Kits\10\lib\10.0.22000.0\ucrt\x86" "/LIBPATH:D:\Windows Kits\10\lib\10.0.22000.0\um\x86" /EXPORT:PyInit_rolling build\temp.win32-cpython-38\Release\qlib/data/_libs/rolling.obj /OUT:build\lib.win32-cpython-38\qlib\data_libs\rolling.cp38-win_amd64.pyd /IMPLIB:build\temp.win32-cpython-38\Release\qlib/data/_libs\rolling.cp38-win_amd64.lib 正在创建库 build\temp.win32-cpython-38\Release\qlib/data/_libs\rolling.cp38-win_amd64.lib 和对象 build\temp.win32-cpython-38\Release\qlib/data/_libs\rolling.cp38-win_amd64.exp rolling.obj : error LNK2001: 无法解析的外部符号 impPyBaseObject_Type rolling.obj : error LNK2001: 无法解析的外部符号 imp___PyDict_NewPresized rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_SetAttr rolling.obj : error LNK2001: 无法解析的外部符号 impPyUnicode_InternFromString rolling.obj : error LNK2001: 无法解析的外部符号 impPyCFunction_Type rolling.obj : error LNK2001: 无法解析的外部符号 impPyOS_snprintf rolling.obj : error LNK2001: 无法解析的外部符号 impPyThreadState_Get rolling.obj : error LNK2001: 无法解析的外部符号 _impPy_CheckRecursionLimit rolling.obj : error LNK2001: 无法解析的外部符号 impPyErr_SetObject rolling.obj : error LNK2001: 无法解析的外部符号 impPyCode_NewEmpty rolling.obj : error LNK2001: 无法解析的外部符号 impPyErr_GivenExceptionMatches rolling.obj : error LNK2001: 无法解析的外部符号 impPyLong_AsUnsignedLong rolling.obj : error LNK2001: 无法解析的外部符号 impPyErr_WarnEx rolling.obj : error LNK2001: 无法解析的外部符号 impPyExc_RuntimeWarning rolling.obj : error LNK2001: 无法解析的外部符号 impPyFrame_New rolling.obj : error LNK2001: 无法解析的外部符号 impPyExc_DeprecationWarning rolling.obj : error LNK2001: 无法解析的外部符号 impPyImport_ImportModule rolling.obj : error LNK2001: 无法解析的外部符号 imp___PyLong_AsByteArray rolling.obj : error LNK2001: 无法解析的外部符号 impPyImport_ImportModuleLevelObject rolling.obj : error LNK2001: 无法解析的外部符号 impPyErr_Occurred rolling.obj : error LNK2001: 无法解析的外部符号 impPyLong_FromSsize_t rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_GenericGetAttr rolling.obj : error LNK2001: 无法解析的外部符号 impPyTraceBack_Here rolling.obj : error LNK2001: 无法解析的外部符号 imp_PyThreadState_UncheckedGet rolling.obj : error LNK2001: 无法解析的外部符号 impPyExc_RuntimeError rolling.obj : error LNK2001: 无法解析的外部符号 impPyMethod_New rolling.obj : error LNK2001: 无法解析的外部符号 impPyExc_IOError rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_SetAttrString rolling.obj : error LNK2001: 无法解析的外部符号 impPyLong_FromLong rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_GC_UnTrack rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_Hash rolling.obj : error LNK2001: 无法解析的外部符号 impPyExc_MemoryError rolling.obj : error LNK2001: 无法解析的外部符号 impPyInterpreterState_GetID rolling.obj : error LNK2001: 无法解析的外部符号 impPyLong_FromUnsignedLongLong rolling.obj : error LNK2001: 无法解析的外部符号 impPy_GetVersion rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_GetAttr rolling.obj : error LNK2001: 无法解析的外部符号 impPyFloat_AsDouble rolling.obj : error LNK2001: 无法解析的外部符号 impPyLong_AsUnsignedLongLong rolling.obj : error LNK2001: 无法解析的外部符号 _impPy_NoneStruct rolling.obj : error LNK2001: 无法解析的外部符号 impPyLong_AsLongLong rolling.obj : error LNK2001: 无法解析的外部符号 impPyTuple_New rolling.obj : error LNK2001: 无法解析的外部符号 impPyDict_SetItemString rolling.obj : error LNK2001: 无法解析的外部符号 impPyDict_Size rolling.obj : error LNK2001: 无法解析的外部符号 impPyLong_FromLongLong rolling.obj : error LNK2001: 无法解析的外部符号 impPyExc_AttributeError rolling.obj : error LNK2001: 无法解析的外部符号 impPyTuple_GetSlice rolling.obj : error LNK2001: 无法解析的外部符号 impPyErr_SetString rolling.obj : error LNK2001: 无法解析的外部符号 impPyErr_WarnFormat rolling.obj : error LNK2001: 无法解析的外部符号 impPyExc_ValueError rolling.obj : error LNK2001: 无法解析的外部符号 imp___Py_CheckRecursiveCall rolling.obj : error LNK2001: 无法解析的外部符号 impPyLong_FromUnsignedLong rolling.obj : error LNK2001: 无法解析的外部符号 impPyDict_Next rolling.obj : error LNK2001: 无法解析的外部符号 impPyErr_Format rolling.obj : error LNK2001: 无法解析的外部符号 impPyExc_ArithmeticError rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_RichCompare rolling.obj : error LNK2001: 无法解析的外部符号 impPyTuple_Type rolling.obj : error LNK2001: 无法解析的外部符号 imp_Py_FalseStruct rolling.obj : error LNK2001: 无法解析的外部符号 impPyImport_GetModule rolling.obj : error LNK2001: 无法解析的外部符号 impPyFloat_Type rolling.obj : error LNK2001: 无法解析的外部符号 imp_PyLong_FromByteArray rolling.obj : error LNK2001: 无法解析的外部符号 impPyModule_NewObject rolling.obj : error LNK2001: 无法解析的外部符号 impPyMethod_Type rolling.obj : error LNK2001: 无法解析的外部符号 impPyLong_Type rolling.obj : error LNK2001: 无法解析的外部符号 impPyErr_Restore rolling.obj : error LNK2001: 无法解析的外部符号 impPyUnicode_Join rolling.obj : error LNK2001: 无法解析的外部符号 impPyExc_OverflowError rolling.obj : error LNK2001: 无法解析的外部符号 impPyCode_NewWithPosOnlyArgs rolling.obj : error LNK2001: 无法解析的外部符号 _impPy_Dealloc rolling.obj : error LNK2001: 无法解析的外部符号 impPyTuple_GetItem rolling.obj : error LNK2001: 无法解析的外部符号 impPyImport_GetModuleDict rolling.obj : error LNK2001: 无法解析的外部符号 impPyModule_GetDict rolling.obj : error LNK2001: 无法解析的外部符号 impPySequence_GetSlice rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_Free rolling.obj : error LNK2001: 无法解析的外部符号 impPyErr_ExceptionMatches rolling.obj : error LNK2001: 无法解析的外部符号 impPyCapsule_GetPointer rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_GC_Del rolling.obj : error LNK2001: 无法解析的外部符号 impPyErr_Fetch rolling.obj : error LNK2001: 无法解析的外部符号 impPyLong_AsLong rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_ClearWeakRefs rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_Not rolling.obj : error LNK2001: 无法解析的外部符号 impPyUnicode_AsUTF8 rolling.obj : error LNK2001: 无法解析的外部符号 impPyUnicode_FromFormat rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_GetBuffer rolling.obj : error LNK2001: 无法解析的外部符号 impPyList_New rolling.obj : error LNK2001: 无法解析的外部符号 impPyImport_AddModule rolling.obj : error LNK2001: 无法解析的外部符号 impPyType_Ready rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_GetAttrString rolling.obj : error LNK2001: 无法解析的外部符号 impPyErr_Clear rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_RichCompareBool rolling.obj : error LNK2001: 无法解析的外部符号 impPyUnicode_Decode rolling.obj : error LNK2001: 无法解析的外部符号 impPyCapsule_New rolling.obj : error LNK2001: 无法解析的外部符号 imp___PyObject_GenericGetAttrWithDict rolling.obj : error LNK2001: 无法解析的外部符号 impPyDict_SetItem rolling.obj : error LNK2001: 无法解析的外部符号 impPyDict_New rolling.obj : error LNK2001: 无法解析的外部符号 impPyUnicode_Type rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_CallFinalizerFromDealloc rolling.obj : error LNK2001: 无法解析的外部符号 imp_PyDict_GetItem_KnownHash rolling.obj : error LNK2001: 无法解析的外部符号 impPyMem_Free rolling.obj : error LNK2001: 无法解析的外部符号 impPyList_Type rolling.obj : error LNK2001: 无法解析的外部符号 impPyErr_NoMemory rolling.obj : error LNK2001: 无法解析的外部符号 impPyDict_GetItemString rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_GetItem rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_CallObject rolling.obj : error LNK2001: 无法解析的外部符号 impPyModuleDef_Init rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_GC_Track rolling.obj : error LNK2001: 无法解析的外部符号 impPyBytes_FromStringAndSize rolling.obj : error LNK2001: 无法解析的外部符号 impPyImport_Import rolling.obj : error LNK2001: 无法解析的外部符号 impPyDict_DelItem rolling.obj : error LNK2001: 无法解析的外部符号 impPyUnicode_Compare rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_IsSubclass rolling.obj : error LNK2001: 无法解析的外部符号 impPyExc_TypeError rolling.obj : error LNK2001: 无法解析的外部符号 impPyMem_Realloc rolling.obj : error LNK2001: 无法解析的外部符号 impPyCapsule_Type rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_IsTrue rolling.obj : error LNK2001: 无法解析的外部符号 impPyExc_NameError rolling.obj : error LNK2001: 无法解析的外部符号 impPyTuple_Pack rolling.obj : error LNK2001: 无法解析的外部符号 _impPyUnicode_Ready rolling.obj : error LNK2001: 无法解析的外部符号 impPyMem_Malloc rolling.obj : error LNK2001: 无法解析的外部符号 impPyExc_IndexError rolling.obj : error LNK2001: 无法解析的外部符号 impPyExc_ImportError rolling.obj : error LNK2001: 无法解析的外部符号 imp___Py_TrueStruct rolling.obj : error LNK2001: 无法解析的外部符号 impPyExc_SystemError rolling.obj : error LNK2001: 无法解析的外部符号 _impPyObject_GC_New rolling.obj : error LNK2001: 无法解析的外部符号 impPyException_SetCause rolling.obj : error LNK2001: 无法解析的外部符号 impPyType_Modified rolling.obj : error LNK2001: 无法解析的外部符号 impPyTraceBack_Type rolling.obj : error LNK2001: 无法解析的外部符号 impPyUnicode_FromString rolling.obj : error LNK2001: 无法解析的外部符号 imp___PyType_Lookup rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_Size rolling.obj : error LNK2001: 无法解析的外部符号 impPyBuffer_Release rolling.obj : error LNK2001: 无法解析的外部符号 impPyObject_Call rolling.obj : error LNK2001: 无法解析的外部符号 impPyUnicode_FromStringAndSize rolling.obj : error LNK2001: 无法解析的外部符号 impPyExc_ModuleNotFoundError rolling.obj : error LNK2001: 无法解析的外部符号 _impPyObject_GetDictPtr build\lib.win32-cpython-38\qlib\data_libs\rolling.cp38-winamd64.pyd : fatal error LNK1120: 134 个无法解析的外部命令 C:\Users\xing\AppData\Local\Temp\pip-build-env-4muktctc\overlay\Lib\site-packages\setuptools\command\build_py.py:207: _Warning: Package 'qlib.data._libs' is absent from the packages configuration. !!

          ********************************************************************************
          ############################
          # Package would be ignored #
          ############################
          Python recognizes 'qlib.data._libs' as an importable package[^1],
          but it is absent from setuptools' `packages` configuration.

          This leads to an ambiguous overall configuration. If you want to distribute this
          package, please make sure that 'qlib.data._libs' is explicitly added
          to the `packages` configuration field.

          Alternatively, you can also rely on setuptools' discovery methods
          (for example by using `find_namespace_packages(...)`/`find_namespace:`
          instead of `find_packages(...)`/`find:`).

          You can read more about "package discovery" on setuptools documentation page:

          - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

          If you don't want 'qlib.data._libs' to be distributed and are
          already explicitly excluding 'qlib.data._libs' via
          `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
          you can try to use `exclude_package_data`, or `include-package-data=False` in
          combination with a more fine grained `package-data` configuration.

          You can read more about "package data files" on setuptools documentation page:

          - https://setuptools.pypa.io/en/latest/userguide/datafiles.html

          [^1]: For Python, any directory (with suitable naming) can be imported,
                even if it does not contain any `.py` files.
                On the other hand, currently there is no concept of package data
                directory, all directories are treated like packages.
          ********************************************************************************

  !!
    check.warn(importable)
  C:\Users\xing_\AppData\Local\Temp\pip-build-env-4muktctc\overlay\Lib\site-packages\Cython\Compiler\Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: E:\Study\Python\qlib-main\qlib\data\_libs\rolling.pyx
    tree = Parsing.p_module(s, pxd, full_module_name)
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x86\\link.exe' failed with exit code 1120
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pyqlib Failed to build pyqlib ERROR: Could not build wheels for pyqlib, which is required to install pyproject.toml-based projects

VenerableDeity commented 3 months ago

I have resolved the above issue by reinstalling Microsoft Build Tools.

lbycan commented 2 months ago

Hi, I have reinstalled Microsoft Build Tools and pip install pyproject, but it is still wrong with this error. Is there any method that can solve it?

VenerableDeity commented 2 months ago

Hi, I have reinstalled Microsoft Build Tools and pip install pyproject, but it is still wrong with this error. Is there any method that can solve it?

After reinstalling Microsoft Build Tools, I successfully resolved all issues by following the instructions in this link: https://www.bilibili.com/video/BV1ZC4y1Q7AU/?spm_id_from=333.337.search-card.all.click&vd_source=b51775505f30dd0bff940e24b47eae29. Essentially, the required versions for the following libraries - numpy==1.23.5, cython==3.0.2, pandas==1.5.3 - must be satisfied, after which the Qlib can run smoothly.