VSCode
Working with text files can be a great way to start programming, but if you're ready to take your coding skills to the next level, it's time to kick it up a notch by using an Integrated Development Environment (IDE). For me, I've chosen Visual Studio Code (VSCode) as my go-to IDE.
To get started with VSCode these following steps will help you set up your development environment.
Installing VSCode.
To install Visual Studio Code (VS Code), follow these steps:
Download VS Code:
Visit the official Visual Studio Code website at https://code.visualstudio.com/.Choose Your Download:
On the VS Code website, you'll find download links for Windows, macOS, and Linux. Click the appropriate link for your operating system.
Download and Run the Installer:
For Windows: Download the .exe installer and run it. Follow the installation wizard's instructions to install VS Code.
For macOS: Download the .dmg disk image file. Open the disk image, drag the Visual Studio Code application into the Applications folder, and then launch VS Code from the Applications folder.
For Linux: Download the appropriate package for your Linux distribution. Installation methods can vary depending on the distribution. Common package types include .deb (for Debian/Ubuntu) and .rpm (for Red Hat/Fedora). Refer to your distribution's documentation for installation instructions.
Launch Visual Studio Code:
After installation, you can typically find Visual Studio Code in your system's applications menu or by searching for "code" in the application launcher.
That's it! You now have Visual Studio Code installed on your system and are ready to use it for coding and development tasks.
Recommended extensions
In order to supercharge your coding experience with Visual Studio Code (VSCode), I highly recommend installing a set of essential extensions. Below is a list of the recommended extensions that I personally use and find incredibly valuable
Ansible by Red Hat:
Publisher: Red Hat
Description: The Ansible extension provides language support, code completion, and syntax highlighting for Ansible playbooks, tasks, and variables. It helps streamline Ansible automation development within VS Code.
Link: Ansible by Red Hat
Docker by Microsoft:
Publisher: Microsoft
Description: The Docker extension simplifies working with Docker containers and Docker Compose within VS Code. It provides features for managing containers, images, and Dockerfiles.
Link: Docker by Microsoft
HashiCorp Terraform by HashiCorp:
Publisher: HashiCorp
Description: This extension offers rich support for HashiCorp Terraform configuration files (.tf and .tfvars). It provides auto-completion, syntax highlighting, and error checking, making Terraform development easier.
Markdown Preview Mermaid Support by Matt Bierner:
Publisher: Matt Bierner
Description: This extension adds support for rendering Mermaid diagrams in Markdown files. Mermaid is a popular JavaScript library for generating diagrams and flowcharts.
Kubernetes by Microsoft:
Publisher: Microsoft
Description: The Kubernetes extension simplifies Kubernetes cluster management and development. It provides features for viewing, editing, and deploying Kubernetes resources directly from VS Code.
Link: Kubernetes by Microsoft
Python by Microsoft:
Publisher: Microsoft
Description: The Python extension enhances Python development within VS Code. It offers features such as code completion, debugging, linting, and Jupyter Notebook support.
Link: Python by Microsoft
Pylance by Microsoft:
Publisher: Microsoft
Description: Pylance is a Visual Studio Code extension that provides fast and feature-rich Python support using the Pyright static type checking tool. It enhances the Python development experience with features like type checking, auto-completion, and more.
Link: Pylance by Microsoft
YAML by Red Hat:
Publisher: Red Hat
Description: The YAML extension provides enhanced support for working with YAML files in VS Code. It includes syntax highlighting, validation, and error checking, making it useful for editing configuration files and Kubernetes manifests.
Link: YAML by Red Hat
These extensions enhance the functionality of Visual Studio Code for specific development tasks and languages, making it a versatile and powerful code editor. You can install them directly from the Visual Studio Code Marketplace by clicking the provided links or by searching for the extension names within VS Code itself.
Creating a new project/workspace.
Create a new project or workspace in Visual Studio Code (VS Code):
Open Visual Studio Code: Launch VS Code by clicking on its icon in your applications menu or by running the code command in your terminal or command prompt.
Open the Command Palette: To create a new project or workspace, you can use the Command Palette. You can access it by pressing Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS). Alternatively, you can click on "View" in the top menu and select "Command Palette."
Create a New Folder: In the Command Palette, type "Workspaces: Create New Workspace" and select it. This will prompt you to choose a directory for your new workspace.
Choose a Directory: Browse to the directory where you want to create your new project/workspace. You can either select an existing directory or create a new folder.
Save the Workspace Configuration File: After choosing a directory, VS Code will ask you to provide a name for your workspace configuration file (commonly with a .code-workspace extension). You can leave the default name or specify a custom one. This file will store the configuration and settings specific to your workspace.
Add Folders to the Workspace: Once you've created the workspace configuration file, you can add folders to it. These folders represent different parts of your project. Click the "Add Folder to Workspace" button or use the "Add Folder to Workspace..." option from the Command Palette. Select the folders you want to include in your workspace.
Save the Workspace: After adding folders, save your workspace by clicking "File" > "Save Workspace As..." and providing a name for your workspace. This saves the workspace configuration file with the selected folders and settings.
Start Coding: Your new project/workspace is now set up in VS Code. You can start creating files, writing code, and organizing your project within this workspace.
Accessing the Workspace Later: In the future, you can easily open your workspace by going to "File" > "Open Workspace..." and selecting the .code-workspace file you saved earlier. VS Code will restore your project with the configured folders and settings.
Creating a workspace in VS Code allows you to group related projects, folders, and files together, making it convenient for managing and working on complex development tasks. You can switch between different workspaces as needed, and each workspace can have its own unique settings and extensions.
Setting up a virtual environment for Python.
Setting up a virtual environment for Python is a good practice because it allows you to isolate project dependencies and avoid conflicts between different Python projects. Here's how you can set up a virtual environment:
Install Python (if not already installed): Ensure that Python is installed on your system. You can download Python from the official website: Python Downloads.
Open a Terminal or Command Prompt: Open your system's terminal or command prompt. The following steps will be executed from the command line.
python --version
Create a Virtual Environment: Choose a directory where you want to create your virtual environment, and navigate to that directory in the terminal. Then, run the following command to create a virtual environment (replace myenv with the name you prefer for your environment):
python -m venv venv
This will create a directory called myenv (or your chosen name) that contains the virtual environment.
Activate the Virtual Environment: Depending on your operating system, the commands to activate the virtual environment will differ:
On Windows:
venv\Scripts\activate
On macOS and Linux:
source venv/bin/activate
After activation, your command prompt should change to indicate that you are now working within the virtual environment.
Install Packages: While the virtual environment is active, you can use pip to install Python packages. Any packages you install will be isolated to this environment.
Install FastAPI and Uvicorn:
pip install fastapi uvicorn
This command will install both FastAPI and Uvicorn along with any required dependencies.
Verify the Installation: To verify that FastAPI and Uvicorn were installed successfully, you can check their versions:
FastAPI:
fastapi --version
Uvicorn:
uvicorn --version
You should see version information for each package if the installation was successful.
Deactivate the Virtual Environment: When you're done working in the virtual environment, you can deactivate it by running:
deactivate
This will return you to the system's global Python environment.
Remember to activate your virtual environment whenever you work on a project, and deactivate it when you're done. This helps keep your project dependencies separate and organized.