Hello Team,
I am trying to deploy the simple python app.
But , I am getting the following error.
I need help as to how I can include the dependencies in the below python file.
like nltk.download() environment.yml I am getting not found on pip error.
please help me out.
if I add them in
Traceback (most recent call last):
2017-11-30T00:47:03.38+0000 [APP/PROC/WEB/0] ERR File "Application.py", line 14, in
2017-11-30T00:47:03.38+0000 [APP/PROC/WEB/0] ERR sid = SentimentIntensityAnalyzer()
2017-11-30T00:47:03.38+0000 [APP/PROC/WEB/0] ERR File "/home/vcap/deps/0/conda/envs/dep_env/lib/python3.6/site-packages/nltk/sentiment/vader.py", line 200, in init
2017-11-30T00:47:03.38+0000 [APP/PROC/WEB/0] ERR self.lexicon_file = nltk.data.load(lexicon_file)
2017-11-30T00:47:03.38+0000 [APP/PROC/WEB/0] ERR File "/home/vcap/deps/0/conda/envs/dep_env/lib/python3.6/site-packages/nltk/data.py", line 834, in load
2017-11-30T00:47:03.38+0000 [APP/PROC/WEB/0] ERR opened_resource = _open(resource_url)
2017-11-30T00:47:03.38+0000 [APP/PROC/WEB/0] ERR File "/home/vcap/deps/0/conda/envs/dep_env/lib/python3.6/site-packages/nltk/data.py", line 952, in open
2017-11-30T00:47:03.38+0000 [APP/PROC/WEB/0] ERR return find(path, path + ['']).open()
2017-11-30T00:47:03.38+0000 [APP/PROC/WEB/0] ERR File "/home/vcap/deps/0/conda/envs/dep_env/lib/python3.6/site-packages/nltk/data.py", line 673, in find
2017-11-30T00:47:03.38+0000 [APP/PROC/WEB/0] ERR raise LookupError(resource_not_found)
2017-11-30T00:47:03.38+0000 [APP/PROC/WEB/0] ERR LookupError:
2017-11-30T00:47:03.38+0000 [APP/PROC/WEB/0] ERR ******************
with the below details.
-----environment.yml-----------
dependencies:
- pandas
- pip:
- flask
- gunicorn
- flask_restful
- nltk
--------procfile-------
web: python Application.py
--------manifest.yml--------
applications:
- name: flask-python
memory: 512M
instances: 1
command: python Application.py
--------runtime.txt----------
python-3.6.2
-----------Application.py-------------
import json
from flask import Flask, request,jsonify
from flask_restful import Resource, Api
from nltk.classify import NaiveBayesClassifier
from nltk.corpus import subjectivity
from nltk.sentiment import SentimentAnalyzer
from nltk.sentiment.util import *
import nltk
nltk.download('vader_lexicon')
from nltk.sentiment.vader import SentimentIntensityAnalyzer
app = Flask(name)
api = Api(app)
sid = SentimentIntensityAnalyzer()
class RandmMeta(Resource):
def get(self):
d = {}
with open('output.csv', 'r', encoding='utf8', errors='ignore') as f:
reader = csv.reader(f, dialect='excel')
# reader = f.read();
d = {'data': [{'score': i[0], 'sentence': i[1]} for i in reader]}
return random.choice(d['data'])
class NLTKMeta(Resource):
def post(self):
json_data = request.get_json(force=True)
sentence = json_data["sentence"]
polarity = sid.polarity_scores(sentence)
return {'data':polarity}
api.add_resource(NLTKMeta, '/api/score')
api.add_resource(RandmMeta,'/api/random/sentence')
if name == 'main':
app.run()
regards,
Rajath kodandaramu