diff --git a/docs/start/initialization.rst b/docs/start/initialization.rst index 24b270d62..00d5dd477 100644 --- a/docs/start/initialization.rst +++ b/docs/start/initialization.rst @@ -28,7 +28,8 @@ Please follow the steps below to initialize ``Qlib``. provider_uri = "~/.qlib/qlib_data/cn_data" # target_dir qlib.init(provider_uri=provider_uri, region=REG_CN) - +.. note:: + Do not import qlib package in the repository directory of ``Qlib``, otherwise, errors may occur. Parameters ------------------- diff --git a/docs/start/installation.rst b/docs/start/installation.rst index 48daad310..063363766 100644 --- a/docs/start/installation.rst +++ b/docs/start/installation.rst @@ -27,9 +27,6 @@ Please follow the steps below to install ``Qlib``: .. note:: It's recommended to use anaconda/miniconda to setup the environment. ``Qlib`` needs lightgbm and pytorch packages, use pip to install them. - -.. note:: - Do not import qlib in the root directory of ``Qlib``, otherwise, errors may occur. diff --git a/qlib/data/ops.py b/qlib/data/ops.py index ca85baf6c..717f73701 100644 --- a/qlib/data/ops.py +++ b/qlib/data/ops.py @@ -9,10 +9,16 @@ import numpy as np import pandas as pd from .base import Expression, ExpressionOps -from ._libs.rolling import rolling_slope, rolling_rsquare, rolling_resi -from ._libs.expanding import expanding_slope, expanding_rsquare, expanding_resi from ..log import get_module_logger +try: + from ._libs.rolling import rolling_slope, rolling_rsquare, rolling_resi + from ._libs.expanding import expanding_slope, expanding_rsquare, expanding_resi +except ImportError as err: + print(err) + print('Do not import qlib package in the repository directory') + exit(-1) + __all__ = ( "Ref", "Max",