Forums

Difficulty in Installing Modules

Hello When I run these 3 commands in Bash console I get error messages

pip install -r https://raw.githubusercontent.com/Lasagne/Lasagne/master/requirements.txt

pip install https://github.com/Lasagne/Lasagne/archive/master.zip

pip install keras

Can you please tell me what am I doing wrong?

The error messages are: For the first command Exception: Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 317, in run prefix=options.prefix_path, File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 742, in install **kwargs File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 831, in install self.move_wheel_files(self.source_dir, root=root, prefix=prefix) File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 1032, in move_wheel_files isolated=self.isolated, File "/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line 346, in move_wheel_files clobber(source, lib_dir, True) File "/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line 317, in clobber ensure_dir(destdir) File "/usr/local/lib/python2.7/dist-packages/pip/utils/init.py", line 83, in ensure_dir os.makedirs(path) File "/usr/lib/python2.7/os.py", line 157, in makedirs mkdir(name, mode) OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/Theano-0.8.2.dist-info'

For the second command Command "/usr/local/bin/python2.7 -u -c "import setuptools, tokenize;file='/tmp/pip-aZnTq4-build/setup.py';exec(com pile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/ pip-WfNJki-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pi p-aZnTq4-build/

For the third command Exception: Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 317, in run prefix=options.prefix_path, File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 742, in install **kwargs File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 831, in install self.move_wheel_files(self.source_dir, root=root, prefix=prefix) File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 1032, in move_wheel_files isolated=self.isolated, File "/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line 346, in move_wheel_files clobber(source, lib_dir, True) File "/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line 317, in clobber ensure_dir(destdir) File "/usr/local/lib/python2.7/dist-packages/pip/utils/init.py", line 83, in ensure_dir os.makedirs(path) File "/usr/lib/python2.7/os.py", line 157, in makedirs mkdir(name, mode) OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/keras'

See http://help.pythonanywhere.com/pages/InstallingNewModules/

Already tried those. Basically what am I trying to do is make an identical website to this one:

http://ethancaballero.pythonanywhere.com/

https://github.com/ethancaballero/Improved-Dynamic-Memory-Networks-DMN-plus

and then do my own modifications and tests.

Can you please help?

What was the result when you tried?

Collecting https://raw.githubusercontent.com/Lasagne/Lasagne/master/requirements.txt Cache entry deserialization failed, entry ignored Downloading https://raw.githubusercontent.com/Lasagne/Lasagne/master/requirements.txt Cannot unpack file /tmp/pip-GkPBt5-unpack/requirements.txt (downloaded from /tmp/pip-Xfjg5O-build, content-type: text /plain; charset=utf-8); cannot detect archive format Cannot determine archive format of /tmp/pip-Xfjg5O-build

That looks like you have a broken pip cache. Try deleting /tmp/pip-*

I think I managed to install them. Not really sure. I am trying to configure the web ap and the wsgi file. Totally confused so far.

what are you confused about?

The wsgi file configuration and the flask_app.py configuration.

This is my wsgi file:

# The below has been auto-generated for your Flask project

import sys

# add your project directory to the sys.path
project_home = u'/home/Stylianos/Improved-Dynamic-Memory-Networks-DMN-plus'
if project_home not in sys.path:
    sys.path = [project_home] + sys.path

# import flask app but need to call it "application" for WSGI to work
from flask_app import app as application  # noqa

This is my flask_app.py file

# A very simple Flask Hello World app for you to get started with...

from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello from Flask!'

And finally this is a Webapp.py file that is included in the project

""" Webapp """

import glob
import flask
import numpy as np

from main import *

app = flask.Flask(__name__)

seed_val = 42
np.random.seed(seed_val)

task = args = dmn = network_name = test_input = test_q = test_answer = pred_answer = pred_prob = memory_probs = None

@app.route('/')
def index():
    return flask.render_template("index.html")

@app.route('/get/taskType', methods=['GET'])
def get_taskType():
    global task, args, dmn, network_name, test_input, test_q, test_answer, pred_answer, pred_prob, memory_probs

    task = flask.request.args.get('taskType_i')
    task = ''.join(task.split())

    args = dmn_start()

    if task == '2':
        args.babi_id = '2'
        args.load_state = 'states/dmn_smooth.mh3.n80.bs10.d0.01.babi2.epoch129.test0.96979.state'
    elif task == '3':
        args.babi_id = '3'
        args.load_state = 'states/dmn_smooth.mh3.n80.bs10.d0.01.babi3.epoch5.test2.28914.state'
    elif task == '6':
        args.babi_id = '6'
        args.load_state = 'states/dmn_smooth.mh3.n80.bs10.d0.01.babi6.epoch90.test0.01423.state'
    elif task == '17':
        args.babi_id = '17'
        args.load_state = 'states/dmn_smooth.mh3.n80.bs10.d0.1.babi17.epoch498.test1.19528.state'
    else:
        args.babi_id = '2'
        args.load_state = 'states/dmn_smooth.mh3.n80.bs10.d0.01.babi2.epoch129.test0.96979.state'

    args, network_name, dmn = dmn_mid(args)

@app.route('/get/story', methods=['GET'])
def get_story():
    global task, args, dmn, network_name, test_input, test_q, test_answer, pred_answer, pred_prob, memory_probs

    test_input = dmn.test_input
    test_q = dmn.test_q
    test_answer = dmn.test_answer

    question_idx  = np.random.randint(test_q.shape[0])

    return_data = dmn.step(question_idx, 'test')

    story_txt = [dmn.ivocab[k] for i in return_data["inp"] for j in i for k in j]
    question_txt = [dmn.ivocab[j] for i in return_data["q"] for j in i]
    correct_answer = [dmn.ivocab[i] for i in return_data["answers"]]
    pred_answer = [dmn.ivocab[i] for i in return_data["prediction"].argmax(axis=1)]
    pred_prob = [return_data["prediction"][0][i] for i in return_data["prediction"].argmax(axis=1)]

    story_txt = ' '.join(filter(None, story_txt))
    question_txt = ' '.join(filter(None, question_txt))
    correct_answer = correct_answer[0]
    pred_answer = pred_answer[0]
    pred_prob = float(pred_prob[0])

    memory_probs = return_data["attentions"][0]

    story_txt = story_txt.replace(" . ", ".\n")
    question_txt += "?"

    return flask.jsonify({
        "question_idx": question_idx,
        "story": story_txt,
        "question": question_txt,
        "correct_answer": correct_answer,
        #"pred_answer" : pred_answer
    })

@app.route('/get/answer', methods=['GET'])
def get_answer():
    question_idx  = flask.request.args.get('question_idx')
    user_question = flask.request.args.get('user_question', '')

    return flask.jsonify({
        "pred_answer" : pred_answer,
        "pred_prob" : pred_prob,
        "memory_probs": memory_probs.T.tolist()
    })

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5000)

What am I supposed to do to get this website running ? (sorry for the big fonds. I don't know how does formatting work in this forum)

[edited by admin: formatting]

what are the errors that you are seeing? Have you checked your webapp error logs?

I don't see any errors. All I see in the website is "Hello from Flask!" I think the way it supposed to work is, the wsgi file should call the flask file, which in turn should call the webapp file. Or the wsgi file should call the webapp file directly. So what should I put in the wsgi file and the flask file?

The wsgi file can import your webapp directly. Basically you want to pass the wsgi file the app = Flask(__name__) from your webapp.

So I need to change the line

from flask_app import app as application

to what?

Looking at your file structure, I see that you have both a flask_app.py and a web_app.py.

Perhaps it is something like

from web_app import app as application