Forum in maintenance, we will back soon π
Having Issues with Langchain - 'TokenTextSplitter' from 'langchain.text_splitter'
Β Β from langchain.text_splitter import TokenTextSplitter ImportError: cannot import name 'TokenTextSplitter' from 'langchain.text_splitter'
Β
Getting this error while running the Youtube summary script.
Please help
Hi, did you install langchain?
pip install langchain
@admin Hi Hassan Thanks for the response .. I Have installed Lanchain but the issue still persists.
Β
Check if the TokenTextSplitter
class exists within the langchain.text_splitter
import langchain.text_splitter if hasattr(langchain.text_splitter, 'TokenTextSplitter'): print("TokenTextSplitter class exists") else: print("TokenTextSplitter class does not exist")
Posted by: @vinsonkvictorΒ from langchain.text_splitter import TokenTextSplitter ImportError: cannot import name 'TokenTextSplitter' from 'langchain.text_splitter'
Here is the response from Bard (ChatGPT) wasn't as specific with solutions:
Here are the potential causes and solutions: 1. Incorrect Langchain Version: Check your version: pip show langchain Upgrade if necessary: pip install -U langchain Specifically, avoid version 0.0.40: It had known issues with certain modules. 2. Python Version Incompatibility: Langchain 0.0.208 and later require Python 3.10 or newer. Check your version: python --version Upgrade if needed: Install Python 3.10 from https://www.python.org/downloads/ 3. Missing or Corrupted Installation: Reinstall Langchain: pip uninstall langchain && pip install langchain 4. Conflicting Module Names: Check for other modules named text_splitter: pip list Rename or remove them if necessary. 5. Caching Issues: Clear pip cache: pip cache purge Additional Steps: Verify Installation Path: python -c "import langchain; print(langchain.__file__)" Check for Typos: Ensure correct capitalization and spelling in the import statement. Consult Documentation: Refer to the official Langchain documentation for troubleshooting: https://langchain.readthedocs.io/ Seek Community Help: If none of these solutions work, reach out to the Langchain community on GitHub or Discord for further assistance.
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
Guess i am running an older version of Python and hence the lanchain is a previous version missing the class
@vinsonkvictor as @husein-aboul-hasan suggested, try updating the packages