Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NLTK
#1
Hi,

I was trying to install nltk in python 3.13

Installation was successful. But it gives error during testing it below.

>>> import nltk
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    import nltk
  File "C:\Program Files\Python313\Lib\site-packages\nltk\__init__.py", line 139, in <module>
    from nltk.text import *
  File "C:\Program Files\Python313\Lib\site-packages\nltk\text.py", line 30, in <module>
    from nltk.tokenize import sent_tokenize
  File "C:\Program Files\Python313\Lib\site-packages\nltk\tokenize\__init__.py", line 66, in <module>
    from nltk.tokenize.casual import TweetTokenizer, casual_tokenize
  File "C:\Program Files\Python313\Lib\site-packages\nltk\tokenize\casual.py", line 49, in <module>
    import regex  # https://github.com/nltk/nltk/issues/2409
    ^^^^^^^^^^^^
  File "C:\Program Files\Python313\Lib\site-packages\regex\__init__.py", line 1, in <module>
    import regex._main
  File "C:\Program Files\Python313\Lib\site-packages\regex\_main.py", line 417, in <module>
    from regex import _regex_core
  File "C:\Program Files\Python313\Lib\site-packages\regex\_regex_core.py", line 21, in <module>
    from regex import _regex
ImportError: cannot import name '_regex' from partially initialized module 'regex' (most likely due to a circular import) (C:\Program Files\Python313\Lib\site-packages\regex\__init__.py)
>>>
Hope to resolve this ASAP.

Regards,
Dan
likes this post
Reply
#2
by any chance do you have a file named regex.py?It look like you have one and it interfere with the import regex
likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Oct-30-2025, 06:52 AM)buran Wrote: by any chance do you have a file named regex.py?It look like you have one and it interfere with the import regex

yes i have it in 3 places:
C:\program files\Python313\Lib\site-packages\nltk\tokenize
C:\program files\Python313\Lib\site-packages\nltk\stem
C:\program files\Python313\Lib\site-packages\nltk\chunk

so what do i have to do now?
likes this post
Reply
#4
I was expecting you have regex.py that you created somewhere in the CWD. The reason for that suspicion was regex is "partially initialized module 'regex'"
likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
(Oct-30-2025, 09:39 AM)buran Wrote: I was expecting you have regex.py that you created somewhere in the CWD. The reason for that suspicion was regex is "partially initialized module 'regex'"
do i need to delete these files?
likes this post
Reply
#6
(Oct-30-2025, 09:52 AM)danandu Wrote:
(Oct-30-2025, 09:39 AM)buran Wrote: I was expecting you have regex.py that you created somewhere in the CWD. The reason for that suspicion was regex is "partially initialized module 'regex'"
do i need to delete these files?

i didn't created these files.
Reply
#7
No, they are OK and needed
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#8
@danandu: you got @buran 's question wrong. The questions is: in the directory where you executed the python command to start the interactive interpreter: is _in_this_directory_ a file called regex.py?

Regards, noisefloor
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  nltk installs but cannot be imported [SOLVED] sheepog 3 2,777 Jun-07-2025, 10:03 PM
Last Post: Larz60+
  get nltk data Pedroski55 7 11,475 Aug-12-2024, 06:16 AM
Last Post: Pedroski55
  Help with simple nltk Chatbot Extra 3 4,801 Jan-02-2022, 07:50 AM
Last Post: bepammoifoge
  Saving a download of stopwords (nltk) Drone4four 1 17,366 Nov-19-2020, 11:50 PM
Last Post: snippsat
  Installing nltk dependency Eshwar 0 3,245 Aug-30-2020, 06:10 PM
Last Post: Eshwar
  Clean Data using NLTK disruptfwd8 0 4,334 May-12-2018, 11:21 PM
Last Post: disruptfwd8
  Text Processing and NLTK (POS tagging) TwelveMoons 2 6,493 Mar-16-2017, 02:53 AM
Last Post: TwelveMoons
  NLTK create corpora pythlang 5 12,977 Oct-26-2016, 07:31 PM
Last Post: Larz60+
  serious n00b.. NLTK in python 2.7 and 3.5 pythlang 24 27,133 Oct-21-2016, 04:15 PM
Last Post: pythlang
  Corpora catalof for NLTK Larz60+ 1 5,400 Oct-20-2016, 02:31 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020