Skip to content

fix: add pandas to filesystem source dependencies#3887

Open
Bhagwat-45 wants to merge 1 commit intodlt-hub:develfrom
Bhagwat-45:fix/3876-add-pandas-to-filesystem-requirements
Open

fix: add pandas to filesystem source dependencies#3887
Bhagwat-45 wants to merge 1 commit intodlt-hub:develfrom
Bhagwat-45:fix/3876-add-pandas-to-filesystem-requirements

Conversation

@Bhagwat-45
Copy link
Copy Markdown

Description

Running dlt init filesystem <destination> followed by pip install -r requirements.txt
does not install pandas. However, the generated pipeline uses read_csv() which requires
pandas, causing a confusing ModuleNotFoundError at runtime.

Changes:

  • Add pandas>=1.3.0 to the filesystem extra in pyproject.toml so it is included
    when running pip install -r requirements.txt after dlt init filesystem
  • Add MissingDependencyException in _read_csv for a clear, actionable error message
    if pandas is not installed
  • Update uv.lock to reflect new pandas dependency

Related Issues

Additional Context

The fix follows the same MissingDependencyException pattern already used in
dlt/sources/sql_database/helpers.py for optional dependencies like connectorx.

@zilto zilto self-assigned this May 5, 2026
Copy link
Copy Markdown
Collaborator

@zilto zilto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. pandas should be an optional dependency for the filesystem source because not all users of filesystem are using read_csv().

Your approach to import pandas inside _read_csv() inside a try/except block is correct.

Though, we have a convention for this. Instead, you can simply do from dlt.common.libs.pandas import pandas. This file at dlt/common/libs/pandas.py already includes the try/except block

Comment thread dlt/sources/filesystem/readers.py Outdated
@@ -1,5 +1,5 @@
from typing import TYPE_CHECKING, Any, Iterable, Iterator, Optional

from dlt.common.exceptions import MissingDependencyException
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to remove

Comment thread dlt/sources/filesystem/readers.py Outdated
Comment on lines +26 to +29
try:
import pandas as pd
except ImportError:
raise MissingDependencyException("filesystem reader (read_csv)", ["pandas"])
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove try/except. Instead do from dlt.common.libs import pandas

Comment thread pyproject.toml Outdated
filesystem = [
"s3fs>=2022.4.0",
"botocore>=1.28",
"pandas>=1.3.0",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove dependency and revert changes to uv.lock accordingly.

- Add pandas>=1.3.0 to the filesystem extra in pyproject.toml so
  it is included when running pip install -r requirements.txt after
  dlt init filesystem
- Add MissingDependencyException in _read_csv for a clear, actionable
  error message if pandas is not installed
- Update uv.lock to reflect new pandas dependency

Closes dlt-hub#3876
@Bhagwat-45 Bhagwat-45 force-pushed the fix/3876-add-pandas-to-filesystem-requirements branch from 57ec222 to b6f4b24 Compare May 6, 2026 03:12
@Bhagwat-45
Copy link
Copy Markdown
Author

Hi @zilto, I've addressed all the requested changes:

Replaced the try/except block with from dlt.common.libs import pandas as pd
Removed the MissingDependencyException import
Reverted pyproject.toml and uv.lock

Please let me know if anything else needs to be changed!

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 this pull request may close these issues.

Pipeline example dependencies don't include an install of pandas to support read_csv

2 participants