Skip to content

Latest commit

 

History

History
135 lines (87 loc) · 5.01 KB

02-local-env.en.md

File metadata and controls

135 lines (87 loc) · 5.01 KB

STEP2: Building local environment

Choose either Python or Go and build your local environment.


Building Python environment

1. Install Python

  • If your local version is below Python3.8, install Python3.10.
  • If you have Python3.8 or above, you can skip the installation step.

2. Check your Python version

  • Check if the Python is added to your PATH (usable as commands on your terminal) with the following command.
$ python -V

If the version does not correspond to the Python version you installed, double check your installation as it is not added to your PATH.

📖 Reference

3. Install dependencies

The list of dependent libraries is written in a file called requirements.txt in a typical Python project. You can install the dependencies by running the following command.

$ cd python

# Create virtual environment for this application
$ python -m venv .venv
$ source .venv/bin/activate
# When you use non-UNIX os, the activation method is different.

# Install required library
$ pip install -r requirements.txt

If you added a library, make sure you add it to requirements.txt.

python -m venv .venv is a command to create a Python virtual environment. A virtual environment is a way to create a project-specific Python environment. Using a virtual environment allows you to manage necessary packages separately for each project so that you can avoid dependency conflicts between different projects. Once the virtual environment is created, it must be activated by the source .venv/bin/activate command.

4. Run the Python app

$ uvicorn main:app --reload --port 9000

If successful, you can access the local host http://127.0.0.1:9000 on our browser and you will see{"message": "Hello, world!"}.


Building Go environment

1. Install Go

  • If your local version is below Go1.20, install Go1.21.
  • If you have Go1.20 or above, you can skip the installation step.

Download it from this link!
※ If you are using a Mac and are unsure whether to download the x86-64 or ARM64 version, click on the Apple logo at the top left corner > select "About This Mac". If the chip is listed as "Apple" choose ARM64; if it's "Intel" select x86-64.

2. Check your Go version

  • Check if Go is added to your PATH (usable as commands on your terminal) with the following command.
$ go version

If the version does not correspond to the Python version you installed, double check your installation as it is not added to your PATH.

📖 Reference

Recommendation web page about Go

3. Install dependencies

In Go, dependent libraries are managed in a file called go.mod. You can install the dependencies by running the following command.

$ cd go
$ go mod tidy

🔰 Point

Understand the role of go.mod and the commands around it referring to this document.

4. Run the Go app

$ go run app/main.go

If successful, you can access the local host http://127.0.0.1:9000 on our browser and you will see{"message": "Hello, world!"}.


🔰 Points

  • If you're using Linux or Mac, understand when and how .bash_profile and .bashrc are activated and used (or .zshrc if you're using zsh).
  • Understand what it means to add to PATH.

📖 Reference

The following resources are useful to dive deeper into building environments and Linux.


Next

STEP3: Make a listing API