Documentation

Installation Guide

NIFTY 50 Stock Price Prediction using LSTM and Flask: AI Final Year Project with Source Code

Step-by-step Setup Verified Instructions Chat Support
Back to Project
Complete Guide

Installation Guide: NIFTY 50 Stock Price Prediction

Don't worry if you've never set up a Python project before. Follow these steps in order and you'll have the dashboard running in about 15–20 minutes. Most of that time is TensorFlow downloading.

Prerequisites

  • Python 3.10. Get 3.10.11 from python.org. Not 3.12, and definitely not 2.7. The models were trained on Python 3.10 with TensorFlow, and sticking to that version avoids most problems. On Windows, tick "Add Python to PATH" during installation.
  • About 2 GB of free disk space. TensorFlow is big.
  • An internet connection for the pip install step.
  • VS Code (optional but helpful) and Jupyter, only if you want to open the training notebooks.

Step-by-Step Setup

  1. Extract the project. Unzip the folder you downloaded somewhere simple, like D:\projects\nifty-predictor. Avoid paths with spaces or very long names. Open Command Prompt or Terminal inside that folder.

  2. Check your Python version. Run:

    python --version

    It should say 3.10.x. If it shows something else, you probably have several Python versions installed. On Windows, try py -3.10 --version instead.

  3. Create a virtual environment.

    python -m venv .venv

    Then activate it.

    Windows:

    .venv\Scripts\activate

    macOS / Linux:

    source .venv/bin/activate

    You'll see (.venv) at the start of the line. That means it worked.

  4. Install the dependencies.

    pip install -r requirements.txt

    This installs Flask, pandas, numpy, scikit-learn, tensorflow, joblib and waitress. Grab a chai. This takes a few minutes.

  5. Run the app.

    python run.py

    Open http://127.0.0.1:5000 in your browser. You should see the stock gallery.

  6. (Optional) Run it in production mode.

    python wsgi.py

    This serves the app on port 8000 using Waitress, which works on Windows.

No environment variables or API keys are needed. The dataset and trained models are already included.

How to Verify It's Working

  • Open http://127.0.0.1:5000/healthz. It should show {"status": "ok", "symbols_loaded": 49}.
  • Go to /stock/RELIANCE. You should see the candlestick chart, the backtest chart and a prediction card with RMSE, MAE, MAPE and R².
  • Open /predict, pick TCS, then change the "predict as of" date to something in 2015. The forecast should update.
  • Open /api/symbols to confirm the API returns a JSON list of stocks.

Common Issues

  • The TensorFlow install fails or says "no matching distribution". You're almost certainly on the wrong Python version, often 3.12 or 3.13. Install 3.10.11, delete the .venv folder, and redo steps 3 and 4.
  • "Address already in use" or a port error. An old run.py is still running in another terminal. Close it with Ctrl+C, or change the port number in run.py.
  • A 404 or "No trained model available" on a stock page. If it's INFRATEL, that's expected, since it didn't have enough history to train. For any other stock, check that its _lstm_model.keras, _scaler.gz and _config.json files are in the models/ folder.
  • The first click on a stock is slow. That's normal. The model loads the first time and stays cached after that.

Still stuck? Message the CodeAj team with a screenshot of the error and we'll sort it out with you on a call.

Need Help?

Our team is here to assist you with installation and setup.

Chat with Us