microsoft/qlib · error · ValueError
{self.storage_name} not exists: {self.uri}
Error message
{self.storage_name} not exists: {self.uri} What it means
Raised by FileStorageMixin.check (qlib/data/storage/file_storage.py) when the computed uri (provider data path + storage folder + file name) does not exist on the filesystem. After the freq was validated, the specific storage artifact (calendar, instruments, or features file) itself is missing. It signals an incomplete or misnamed data directory rather than a wrong API call.
Source
Thrown at qlib/data/storage/file_storage.py:73
freq_l = [Freq(freq) for freq in freq_l]
setattr(self, _v, freq_l)
return freq_l
@property
def uri(self) -> Path:
if self.freq not in self.support_freq:
raise ValueError(f"{self.storage_name}: {self.provider_uri} does not contain data for {self.freq}")
return self.dpm.get_data_uri(self.freq).joinpath(f"{self.storage_name}s", self.file_name)
def check(self):
"""check self.uri
Raises
-------
ValueError
"""
if not self.uri.exists():
raise ValueError(f"{self.storage_name} not exists: {self.uri}")
class FileCalendarStorage(FileStorageMixin, CalendarStorage):
def __init__(self, freq: str, future: bool, provider_uri: dict = None, **kwargs):
super(FileCalendarStorage, self).__init__(freq, future, **kwargs)
self.future = future
self._provider_uri = None if provider_uri is None else C.DataPathManager.format_provider_uri(provider_uri)
self.enable_read_cache = True # TODO: make it configurable
self.region = C["region"]
@property
def file_name(self) -> str:
return f"{self._freq_file}_future.txt" if self.future else f"{self._freq_file}.txt".lower()
@property
def _freq_file(self) -> str:
"""the freq to read from file"""
if not hasattr(self, "_freq_file_cache"):View on GitHub (pinned to 79633dd950)
Solutions
- Inspect the failing uri printed in the error: verify each path component exists and matches the expected layout (calendars/, instruments/, features/<inst>/<day>.bin).
- Download or re-dump the qlib bin data for your region and market (qlib's get_data / dump_bin tooling).
- Correct C["provider_uri"] to the actual data root — the folder that directly contains calendars/.
- If only some instruments are missing, restrict instruments to those dumped, or re-dump the missing ones.
Example fix
# before import qlib qlib.init(provider_uri="~/.qlib/qlib_data/cn_data") # dir empty or wrong # after # ensure the folder contains calendars/, instruments/, features/: # ls ~/.qlib/qlib_data/cn_data -> calendars instruments features qlib.init(provider_uri="~/.qlib/qlib_data/cn_data")
Defensive patterns
Strategy: validation
Validate before calling
root = Path(provider_uri)
for sub in ("calendars", "instruments", "features"):
if not (root / sub).is_dir():
raise FileNotFoundError(f"incomplete qlib data at {root}: missing {sub}/") Type guard
def qlib_data_complete(provider_uri: str) -> bool:
root = Path(provider_uri)
return all((root / s).is_dir() for s in ("calendars", "instruments", "features")) Try / catch
try:
storage.check()
except ValueError as e:
if "not exists" in str(e):
logger.error("qlib data incomplete: %s", e)
raise SystemExit("re-download or re-dump qlib bin data") from e
raise Prevention
- Verify the data root layout right after qlib.init in every entrypoint.
- Pin data dump scripts and data versions together with the qlib package version.
When it happens
Trigger: provider_uri points at an empty or partially-populated directory (calendars exist but instruments/ or features/ missing); the file for a specific instrument is absent because data was dumped selectively; wrong region data path (cn_data vs us_data) in C.setdefault('provider_uri', ...).
Common situations: First-run setups where the data was never downloaded; partial dumps interrupted midway; pointing provider_uri at the wrong folder (e.g. the qlib repo instead of the data dir); instruments market files (e.g. csi300.txt) not present.
Related errors
- I forget why would this case appear. But I think it does not
- stock selector must be type str|list, or slice(None), rather
- {self.storage_name}: {self.provider_uri} does not contain da
- type(i) = {type(i)}
- {i}: start index is {storage_start_index}
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/7fb575676bfbca04.
Report an issue: GitHub.