Score:0

ModuleNotFoundError: No module named 'regex._regex'

mc flag

I spent the entire night trying to find where my code is breaking, and finally narrowed it down to this. This is the full error message that i received:

"Traceback (most recent call last): 
File "/var/www/html/ngram_pos/service/word_service/checker.py", line 11, in import nltk # type: ignore 
File "/var/www/html/ngram_pos/service/word_service/../../src/nlp_nltk_3.6.2_deb/nltk/__init__.py", line 133, in from nltk.text import * 
File "/var/www/html/ngram_pos/service/word_service/../../src/nlp_nltk_3.6.2_deb/nltk/text.py", line 30, in from nltk.tokenize import sent_tokenize 
File "/var/www/html/ngram_pos/service/word_service/../../src/nlp_nltk_3.6.2_deb/nltk/tokenize/__init__.py", line 66, in from nltk.tokenize.casual import TweetTokenizer, casual_tokenize 
File "/var/www/html/ngram_pos/service/word_service/../../src/nlp_nltk_3.6.2_deb/nltk/tokenize/casual.py", line 38, in import regex # https://github.com/nltk/nltk/issues/2409 
File "/var/www/html/ngram_pos/service/word_service/../../src/nlp_nltk_3.6.2_deb/regex/__init__.py", line 1, in from .regex import * 
File "/var/www/html/ngram_pos/service/word_service/../../src/nlp_nltk_3.6.2_deb/regex/regex.py", line 419, in import regex._regex_core as _regex_core 
File "/var/www/html/ngram_pos/service/word_service/../../src/nlp_nltk_3.6.2_deb/regex/_regex_core.py", line 21, in import regex._regex as _regex ModuleNotFoundError: No module named 'regex._regex' "

I am running this on an ubuntu server, version 22.04. The python version is 3.10.

Source code is a PHP file, where the main problem statement is this:

$str_output = shell_exec($command_exec);

Where

$command_exec = python3 checker.py 'what ;should ;I ;avoid ;while ;writing ;in ;English ;what should ;should I ;I avoid ;avoid while ;while writing ;writing in ;in English ;what should I ;should I avoid ;I avoid while ;avoid while writing ;while writing in ;writing in English ' ';' 2>&1

checker.py is the python file that the code in PHP is running through shell, and the rest of the problem statements can be seen through the error message, which highlights all of them.

Further elaboration: I am working on a local server in Ubuntu, where all the files were given to me.

I am really new to all this so please tell me what all information is needed to solve this issue

ru flag
I think you need StackOverflow and your code shared to properly get an answer, I don't see how this is an Ubuntu issue as it currently stands. What OS are you using? What python version?
Minion avatar
mc flag
Really sorry, i am so sleep deprived i forgot to mention the basic stuff. I am using an ubuntu server 22.04. The python version is 3.10.
ru flag
It looks like the Regex module in this case is bundled with the whole software and NOT from the system repos or PyPI. Unfortunately, that makes solving this very limited. Are you working in a venv or something? As it currently reads, it looks like you're doing everything from source code and that'll make it very very difficult to fix/debug. We also don't have **the rest of your code** which may be necessary here. My suggestion would be go get some sleep then come back with the info we need
Minion avatar
mc flag
Added the part of the source code that was causing the issue. Also i dont really understand what you mean by "doing everything from source code". I am not using venv.
ru flag
This path refers to a *copy* of regex for the application: `/var/www/html/ngram_pos/service/word_service/../../src/nlp_nltk_3.6.2_deb/regex/_regex_core.py` - this means wherever you got the code for your site from it's working of a *local copy* and *NOT* inheriting PyPI or other packages, so it suggests that something is up within your source code tree regarding libraries and source code. That means that that component needs updated, checked, etc. and because you aren't using a venv this is how I know everyhting's using a "local copy" of a version of a specific library/deps we can't really fix
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.