Activity: Setting Up Python 3.
6 with Flask Using Anaconda on Ubuntu
Objective:
Students will learn to install Anaconda, create a virtual environment, and configure it with
Python 3.6 and Flask on Linux Ubuntu.
Steps for the Activity
Part 1: Install Anaconda
1. Download Anaconda:
o Open the terminal and run the following command to download the latest
Anaconda installer:
wget [Link]
o (Replace the version if a newer one is available.)
2. Install Anaconda:
o Run the installer script:
bash Anaconda3-2023.11-Linux-x86_64.sh
o Follow the prompts and accept the license terms. Confirm the installation
path (default is recommended).
3. Initialize Anaconda:
o After installation, initialize Anaconda:
source ~/.bashrc
conda init
o Restart the terminal to apply changes.
Part 2: Create a Virtual Environment
1. Create a New Environment with Python 3.6:
o In the terminal, run:
conda create --name flask_env python=3.6
o This command creates a virtual environment named flask_env with Python
3.6.
2. Activate the Environment:
o Run the following command to activate the environment:
conda activate flask_env
Part 3: Install Flask
1. Install Flask in the Environment:
o While in the flask_env environment, install Flask using pip:
pip install flask
2. Verify Installation:
o Confirm Flask is installed:
python -m flask --version
Part 4: Test Flask
1. Create a Simple Flask App:
o In the terminal, create a file called [Link]:
code [Link]
o Add the following code:
from flask import Flask
app = Flask(__name__)
@[Link]('/')
def home():
return "Hello, Flask!"
if __name__ == "__main__":
[Link](debug=True)
2. Run the Flask App:
o Start the Flask application:
python [Link]
o Open a browser and go to [Link] to see the message:
"Hello, Flask!"
Submission Requirements
• Students must submit:
o A screenshot of their virtual environment setup (conda list).
o A screenshot of the browser showing the Flask app running.
By: Ing. César Sinchiguano, [Link]