- Enable WSL and Required Features via Windows Features
a. Open the Windows search bar.
b. Type "Turn Windows features on or off" and click on the matching result to open the Windows Features dialog.
c. Scroll through the list and check the boxes next to:Windows Subsystem for Linux
Virtual Machine Platform
Hyper-V
- Click "OK" to apply the changes.
- Restart your computer if prompted.
- Download and Install Ubuntu on Windows
a. You can download Ubuntu for free from the Microsoft Store.
b. If you have installed and uninstalled Ubuntu in the past, you may have to do the following in PowerShell:- Run:
wsl --unregister ubuntu
- Run:
wsl --install
- Run:
- Enter a Linux username and password. Don’t forget what they are!
- If you forgot your password
a. Launch Powershell
- Run: ubuntu --default-user root b. Launch Ubuntu
- If you know the username, Run: passwd [username]
- Visit GitHub.com and follow the sign-up process.
- Download VS Code
a. Download and install VS Code from the Visual Studio Code website. - Install the Python Extension for VS Code
a. Open Extensions (Ctrl+Shift+X
) in VS Code and install the Python extension provided by Microsoft. - Install Remote – WSL Extension
a. In Extensions, search for and install the "Remote - WSL" extension. - Install GitHub Repositories and GitHub Actions Extensions for Visual Studio Code
a. In Extensions, search for "GitHub Repositories" by GitHub. - Sign in to GitHub
a. Open the Command Palette by pressingCtrl+Shift+P
.
b. TypeGitHub: Sign in
and select the command.
c. Authenticate with GitHub by following the instructions provided.
- Navigate to Baby-Name-App-Project-Files Repo and click "Fork".
a. Copy the location of your fork by clicking "Code" in the new repo to get the HTML link.
- Open the Command Palette by pressing
Ctrl+Shift+P
and type "WSL: Open Folder in WSL".
a. Navigate to the directory where you want to download the project files. - Click Terminal at the top of VS Code to open a new terminal.
- Change the terminal type from PowerShell to WSL.
a. Click the down arrow next to the "+" and change the terminal type. - Clone the Baby-Name-App repo:
- Run:
git clone <link to the repo>
(e.g.,https://github.com/Chelsea-Myers/Baby-Name-App-Project-Files
)
- Run:
- Verify the directory in the Explorer menu on the left.
- Open the project folder in WSL using the Command Palette.
- Install Prerequisites
a. Run:sudo apt update
b. Run:sudo apt install python3 python3-pip
- Check the Python and pip versions:
a. Run:python3 --version
b. Run:pip3 --version
- Create a Virtual Environment
a. Navigate to the project directory. b. Run:sudo apt install python3.10-venv
C. Run:python3 -m venv venv
- Activate the Virtual Environment
a. Run:source venv/bin/activate
b. Verify that(venv)
appears at the start of your terminal prompt. - Install Project Dependencies
a. Run:pip install -r requirements.txt
- Locate the following files:
data
static
app.py
,LICENSE
,Procfile
,README.md
,requirements.txt
- Edit
app.py
as follows:
a. Under the comment# Load babynames.csv into a Pandas DataFrame
, read in the data using:b. Under the commentbabynames = pd.read_csv('./data/babynames.csv', names=['sex', 'year', 'name', 'count'])
# Construct a column giving the rank within each year and sex
, create arank_in_year
column:c. Under the commentbabynames['rank_in_year'] = babynames.groupby(['year', 'sex'])['count'].rank(ascending=False)
# Extract year and rank in year for the given name-sex combination
:name_subset = babynames[(babynames['name'] == name) & (babynames['sex'] == sex)] name_years = name_subset['year'].tolist() name_ranks = name_subset['rank_in_year'].tolist()
- Save the file.
- Click on Source Control in VS Code.
a. Enter a commit message and click Commit and Push.
- Start the Flask app:
- Run:
flask --app app --debug run
- Run:
- View the app at http://localhost:5000 in your browser.
- Delete the
venv
folder and zip the project directory. - Create a PythonAnywhere account.
- Follow PythonAnywhere's instructions to upload, unzip, and configure your app.
- Open a Bash console.
- Run:
virtualenv venv
- Activate the virtual environment:
- Run:
source venv/bin/activate
- Run:
- Install dependencies:
- Run:
pip install -r requirements.txt
- Run:
- Update the WSGI configuration file as follows:
import sys path = '/home/yourusername/Baby-Name-App' if path not in sys.path: sys.path.append(path) from app import app as application