0
I’m trying to run a script in Python3 that I developed, which is located in a folder within the "Folder app" of Laravel. One script is called by a Controller and the other by an Artisan Command.
public static function searchAnswers($input)
{
$process = new Process(array('dir', base_path() . '/app/SearchEngine'));
$process->setWorkingDirectory(base_path() . '/app/SearchEngine');
$process->setCommandLine('python3 SearchEngine.py ' . '"'. $input .'"');
$process->setTimeout(2 * 3600);
$process->run();
if (!$process->isSuccessful()) { //Executes after the command finishes
throw new ProcessFailedException($process);
}
$list_ids = array_map('intval', explode(' ', $process->getOutput()));
info($list_ids);
$solicitations = Solicitation::join('answers', 'solicitations.id', '=', 'answers.solicitation_id')
->whereIn('solicitations.id', $list_ids)
->limit(20)
->get();
info($solicitations);
return $solicitations;
}
In my localhost environment, the whole integration works perfectly. But, after I uploaded my application to my remote server (Debian), I am getting the following error:
"""
The command "python3 SearchEngine.py "O que é fogo no **?"" failed.\n
\n
Exit Code: 1(General error)\n
\n
Working directory: /var/www/plataformaTS/app/SearchEngine\n
\n
Output:\n
================\n
\n
\n
Error Output:\n
================\n
Traceback (most recent call last):\n
File "/usr/local/lib/python3.4/dist-packages/nltk/corpus/util.py", line 80, in __load\n
try: root = nltk.data.find('{}/{}'.format(self.subdir, zip_name))\n
File "/usr/local/lib/python3.4/dist-packages/nltk/data.py", line 675, in find\n
raise LookupError(resource_not_found)\n
LookupError: \n
**********************************************************************\n
Resource \e[93mstopwords\e[0m not found.\n
Please use the NLTK Downloader to obtain the resource:\n
\n
\e[31m>>> import nltk\n
>>> nltk.download('stopwords')\n
\e[0m\n
Searched in:\n
- '/var/www/nltk_data'\n
- '/usr/share/nltk_data'\n
- '/usr/local/share/nltk_data'\n
- '/usr/lib/nltk_data'\n
- '/usr/local/lib/nltk_data'\n
- '/usr/nltk_data'\n
- '/usr/share/nltk_data'\n
- '/usr/lib/nltk_data'\n
**********************************************************************\n
\n
\n
During handling of the above exception, another exception occurred:\n
\n
Traceback (most recent call last):\n
File "SearchEngine.py", line 20, in <module>\n
stopwords = stopwords.words('portuguese')\n
File "/usr/local/lib/python3.4/dist-packages/nltk/corpus/util.py", line 116, in __getattr__\n
self.__load()\n
File "/usr/local/lib/python3.4/dist-packages/nltk/corpus/util.py", line 81, in __load\n
except LookupError: raise e\n
File "/usr/local/lib/python3.4/dist-packages/nltk/corpus/util.py", line 78, in __load\n
root = nltk.data.find('{}/{}'.format(self.subdir, self.__name))\n
File "/usr/local/lib/python3.4/dist-packages/nltk/data.py", line 675, in find\n
raise LookupError(resource_not_found)\n
LookupError: \n
**********************************************************************\n
Resource \e[93mstopwords\e[0m not found.\n
Please use the NLTK Downloader to obtain the resource:\n
\n
\e[31m>>> import nltk\n
>>> nltk.download('stopwords')\n
\e[0m\n
Searched in:\n
- '/var/www/nltk_data'\n
- '/usr/share/nltk_data'\n
- '/usr/local/share/nltk_data'\n
- '/usr/lib/nltk_data'\n
- '/usr/local/lib/nltk_data'\n
- '/usr/nltk_data'\n
- '/usr/share/nltk_data'\n
- '/usr/lib/nltk_data'\n
**********************************************************************\n
\n
"""
Only, when I run the script directly on my terminal, the results are coming as expected. So the error is not related to installing libs on my server. The script that is called by php Artisan :command also works perfectly.
What might be going on? It’s some server configuration?
Thanks for your help!