1

I have deployed my project in elastic-beanstack, I need to setup python3, numpy and nltk environment to it.

We have a python code with python3, numpy and nltk, We are interacting to python code with nodejs Child process. In my local machine it works good.

To setup on EB, We initiated EB cli in our project and installed python3, numpy, nltk through EB CLI

sudo yum -y update
sudo yum -y install yum-utils
sudo yum -y groupinstall development
sudo yum install pip3

pip3 --version 
--------> pip 19.0.2 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

sudo yum -y install python36u
sudo update-alternatives --config python

python
--------> Python 3.6.7

pip3 install nltk --user
pip3 install numpy --user

pip list

-->Package        Version
nltk           3.4    
numpy          1.16.1 
pi             0.1.2  
pip            19.0.2 
setuptools     36.2.7 
singledispatch 3.4.0.3
six            1.12.0 
wheel          0.33.0 

On executing the output we get error as nltk and numpy packages not fount.

How to setup python3, numpy, nltk in my elastic-beanstalk, Kindly help me on this.

Am I missing or I am totally in a wrong path.

What I am doing

In My Python Script

import sys, json
from nltk import RegexpTokenizer
import pickle
import numpy as np

np.dot(v1, v2)

With Python In my Express(Nodejs)

const { spawn } = require('child_process');
const ls = spawn('python', ['./scoring.py', JSON.stringify(qJSON)]);
ls.stdout.on('data', (data) => {

ERROR stderr: Traceback (most recent call last): stderr: File

"./scoring.py", line 7 stderr: from nltk import RegexpTokenizer

stderr: ImportErrorstderr: : stderr: No module named nltkstderr:

child process exited with code 1

With Python3 In my Express(Nodejs)

const { spawn } = require('child_process');
const ls = spawn('python3', ['./scoring.py', JSON.stringify(qJSON)]);
ls.stdout.on('data', (data) => {

Error: spawn python3 ENOENT at Process.ChildProcess._handle.onexit

(internal/child_process.js:232:19) at onErrorNT

(internal/child_process.js:407:16) at process._tickCallback

(internal/process/next_tick.js:63:19)Emitted 'error' event at: at

Process.ChildProcess._handle.onexit (internal/child_process.js:238:12)

at onErrorNT (internal/child_process.js:407:16) at

process._tickCallback (internal/process/next_tick.js:63:19)

enter image description here

fernandus
  • 143
  • 1
  • 9

1 Answers1

0

The nltk and numpy packages do not come with any executable scripts.

To verify that your installation was successful try to load the libraries in Python:

$ python
Python 3.6.8 (default, Feb  6 2019, 12:07:20) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> import nltk
>>> import numpy
>>> 

If the two import statements don't throw any errors the package installation went through ok and you can use the modules in your programs.

Hope that helps :)

MLu
  • 24,849
  • 5
  • 59
  • 86
  • I have check with import nltk and nimpy no error, But still getting ImportError No module named nltk – fernandus Feb 19 '19 at 09:24
  • @fernandus are you using the correct Python? Maybe you’ve got both `python2` and `python3` installed and your program uses the wrong one? Try also imstalling the modules with `pip2 install —user nltk numpy` or call your program explicitly with Python 3 as `python3 /path/to/your/program`. If `import nltk` works in interactive shell but not in your program it’s likely a different python version. – MLu Feb 19 '19 at 09:47
  • How to find my /path/to/your/program in EB, how can i change my project to use python3? – fernandus Feb 19 '19 at 11:00
  • Update your question above with the exact error output. I.e. what do you run and what does it print. We need to see what exactly you’re doing that triggers the error. – MLu Feb 19 '19 at 11:20
  • I have updated the error – fernandus Feb 19 '19 at 13:36
  • I am deploying express using Source Bundle in eb – fernandus Feb 19 '19 at 15:49
  • I Deployed the project in DigitalOcean everything works fine, But with AWS its not I cant do spawn('python3', ['./scoring.py', JSON.stringify(qJSON)]). But I have Python3 with nltk and numpy. – fernandus Feb 22 '19 at 07:10