Skip to content

Forum in maintenance, we will back soon πŸ™‚

Having Issues with ...
 
Notifications
Clear all

Having Issues with Langchain - 'TokenTextSplitter' from 'langchain.text_splitter'

11 Posts
5 Users
4 Reactions
11 Views
(@vinsonkvictor)
Posts: 5
Active Member
Topic starter
 

Β Β 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

 
Posted : 12/26/2023 8:51 am
Hasan Aboul Hasan
(@admin)
Posts: 1276
Member Admin
 

Hi, did you install langchain?

pip install langchain
 
Posted : 12/26/2023 8:57 am
(@vinsonkvictor)
Posts: 5
Active Member
Topic starter
 

@admin Hi Hassan Thanks for the response .. I Have installed Lanchain but the issue still persists.

Β 

This post was modified 12 months ago by Vinson Kochumannil Victor
 
Posted : 12/26/2023 9:09 am
Hasan Aboul Hasan
(@admin)
Posts: 1276
Member Admin
 

@vinsonkvictor please can you show me a screenshot of the error

 
Posted : 12/26/2023 12:10 pm
(@husein)
Posts: 550
Member Moderator
 

@vinsonkvictor Hello friend, try updating the package:

pip install --upgrade langchain
 
Posted : 12/26/2023 12:19 pm
(@yasser-helbawi)
Posts: 6
Active Member Customer
 

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 : 12/26/2023 12:41 pm
(@vinsonkvictor)
Posts: 5
Active Member
Topic starter
 

@yasser-helbawi no the class is not found.

 
Posted : 12/26/2023 4:25 pm
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

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

 
Posted : 12/26/2023 7:17 pm
(@vinsonkvictor)
Posts: 5
Active Member
Topic starter
 

Guess i am running an older version of Python and hence the lanchain is a previous version missing the class

 
Posted : 12/27/2023 5:58 am
Hasan Aboul Hasan
(@admin)
Posts: 1276
Member Admin
 

@vinsonkvictor as @husein-aboul-hasan suggested, try updating the packages

 
Posted : 12/27/2023 6:13 am
(@vinsonkvictor)
Posts: 5
Active Member
Topic starter
 

@admin Upgraded Python.. It works now.. Thanks

 
Posted : 12/27/2023 12:43 pm
Share:
[the_ad_group id="312"]