Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import name 'ExperimentalMarkdownSyntaxTextSplitter' from 'langchain_text_splitters' #30388

Closed
5 tasks done
tko85 opened this issue Mar 19, 2025 · 2 comments
Closed
5 tasks done
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@tko85
Copy link

tko85 commented Mar 19, 2025

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

The ExperimentalMarkdownSyntaxTextSplitter line in the below python code generated an error:

%pip install -qU langchain-text-splitters
from langchain_text_splitters import MarkdownHeaderTextSplitter
from langchain_text_splitters import ExperimentalMarkdownSyntaxTextSplitter

Error Message and Stack Trace (if applicable)

ImportError: cannot import name 'ExperimentalMarkdownSyntaxTextSplitter' from 'langchain_text_splitters' (/opt/conda/envs/Python-RT24.1/lib/python3.11/site-packages/langchain_text_splitters/init.py)

Description

I'm trying to use the ExperimentalMarkdownSyntaxTextSplitter but get an error when i try to import the package.

System Info

System Information

OS: Linux
OS Version: #225-Ubuntu SMP Fri Jan 10 22:23:35 UTC 2025
Python Version: 3.11.9 (main, Apr 19 2024, 16:48:06) [GCC 11.2.0]

Package Information

langchain_core: 0.3.46
langchain: 0.3.4
langchain_community: 0.3.3
langsmith: 0.1.126
langchain_chroma: 0.1.4
langchain_docling: 0.2.0
langchain_elasticsearch: 0.3.0
langchain_ibm: 0.3.1
langchain_milvus: 0.1.6
langchain_text_splitters: 0.3.7
langgraph_sdk: 0.1.51

Optional packages not installed

langserve

Other Dependencies

aiohttp: 3.11.10
async-timeout: Installed. No version info available.
chromadb: 0.4.13
dataclasses-json: 0.6.7
docling: 2.27.0
elasticsearch[vectorstore-mmr]: Installed. No version info available.
fastapi: 0.115.2
httpx: 0.27.0
ibm-watsonx-ai: 1.2.10
jsonpatch<2.0,>=1.33: Installed. No version info available.
langchain-core<1.0.0,>=0.3.45: Installed. No version info available.
langsmith<0.4,>=0.1.125: Installed. No version info available.
numpy: 1.26.4
orjson: 3.10.2
packaging<25,>=23.2: Installed. No version info available.
pydantic: 2.8.2
pydantic-settings: 2.6.0
pydantic<3.0.0,>=2.5.2;: Installed. No version info available.
pydantic<3.0.0,>=2.7.4;: Installed. No version info available.
pymilvus: 2.4.4
PyYAML: 6.0.1
PyYAML>=5.3: Installed. No version info available.
requests: 2.32.2
SQLAlchemy: 2.0.25
tenacity: 8.2.2
tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available.
typing-extensions>=4.7: Installed. No version info available.

@dosubot dosubot bot added the 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature label Mar 19, 2025
@YassinNouh21
Copy link

Hi @tko85,

I've investigated the issue and reproduced it in an environment matching your setup. The issue appears to be related to how Python is finding the package. Here's what I found:

  1. The ExperimentalMarkdownSyntaxTextSplitter class is definitely present in the package and is properly exported in __init__.py.

  2. The issue might be related to how Python is resolving the package path. Let's try these steps to fix it:

    # First, completely remove the package
    pip uninstall langchain-text-splitters
    
    # Clear pip's cache
    pip cache purge
    
    # Reinstall with the --no-cache-dir flag
    pip install --no-cache-dir langchain-text-splitters==0.3.7
  3. After installation, verify the package is installed correctly:

    pip show langchain-text-splitters
  4. If you're using a Jupyter notebook (as indicated by the %pip command in your example), make sure to restart the kernel after installation.

  5. You can also try importing the package this way:

    from langchain_text_splitters.markdown import ExperimentalMarkdownSyntaxTextSplitter

If the issue persists after trying these steps, could you please provide:

  1. The output of pip show langchain-text-splitters
  2. The output of python -c "import langchain_text_splitters; print(langchain_text_splitters.__file__)"

This will help us understand exactly how Python is resolving the package path on your system.

Also, since you're using Ubuntu Linux, make sure you have the appropriate permissions for the Python site-packages directory where pip installs packages.

Let me know if you need any clarification or if the issue persists after trying these steps.

@tko85
Copy link
Author

tko85 commented Mar 24, 2025

These steps resolved the issue.
Thank you.

@tko85 tko85 closed this as completed Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants