Python Environment -  venv & Docker (locally and GitHub)

Python Environment - venv & Docker (locally and GitHub)

Introduction

The video introduces the topic of installing Docker and Visual Studio Code for Windows.

Installing Docker

  • To install Docker, go to docker.com and click on "Download Docker Desktop for Windows."
  • Open the executable file to start the installation of Docker.
  • This installation will require restarting your computer.
  • After the installation, click on "Close and Restart." This action will restart your computer.
  • If you currently don't have WSL kernel installed, you have to install it now. Go to the link in the message box; it will open a website with instructions on how to install it.
  • Click on this link to download WSL. When the file is downloaded, execute it and follow these steps.
  • When the installation is complete, you have to close Docker and restart it so that changes take effect.

Installing Visual Studio Code

  • To install Visual Studio Code, go to this website and download it for Windows.
  • Execute the downloaded file and follow these steps. Let's keep the default settings and press next and then install.
  • To use Visual Studio with a Docker container, you have to add the extension Dev containers by clicking on "Install."

Creating a Python Environment

The video explains how to create a Python environment using Docker.

Creating an Environment for Python

  • Go back to our Docker container to create our environment for python. Click "Get Started" and then check local directory. Please give it a name and click select to specify the path for your local directory. Select the folder and press continue depending on where the folder you want

to use is located; it will require you to open Docker as administrator.

  • If you get an error when trying to create a Dev environment using a local directory, try running Docker as administrator.
  • When the environment is complete, press "Done" or go directly and click "Open in VS Code" to open Visual Studio Code.

Using Visual Studio Code

  • Now that our environment is attached to our local Dev folder, we can create files in VS Code, and the files will be available in both places: the Docker environment and your local folder.
  • VS Code will prompt some recommendations about installing extensions like Python. I also recommend installing each recommended extension.

Running Python Code

The video explains how to run Python code using Docker.

Checking the System

  • Let's run apt-get update to get the system up-to-date.
  • Your development environment is isolated from your operating system. If we run the command uname -a, we will see the details of the operating system where our python environment is running.

Installing PIP

  • One library that we used for installing other libraries is PIP. To use it, we need to install it by running the following command:

apt-get install python3-pip

  • To check the version, run pip3 --version.

Running a Simple Print Code

  • Now let's run a simple print code to ensure we can run python code:

print("Hello World!")

Using GitHub Repository with Docker Dev Environment

The video explains how to use GitHub repository with Docker Dev Environment.

Creating a GitHub Repository

  • You can use Docker Dev Environment with GitHub repository. To create it, click on "Create" button, then "Get Started," and give it a name.
  • You need a GitHub account to use them with Docker Dev Environment. You can sign in or create an account. If you do not already have an account, create a repository if you still don't have one and copy the repo link.
  • Press "Continue."

Installing Git

  • If you get an error like this, that means you still don't have Git on your computer. So let's install it. Click on "Install" to open this website, find the Windows version of the setup, and click on the link.
  • Execute the downloaded file and install Git. Click on next and keep the default settings.

Creating a New File and Synchronizing with GitHub

This section covers how to create a new file in Visual Studio Code and synchronize it with GitHub.

Steps for Synchronization

  • Click on the get icon to commit your files into GitHub using Visual Studio.
  • Click on the plus icon to stage your file.
  • Give the commit a short description and click the commit button.
  • If this is the first time you are doing this, you will need to configure your username and email. Execute the following commands using your username and email that you used when you created your GitHub account.
  • If there are no stage changes, delete the composed Dev file that was generated during dev environment creation.
  • If you don't see your file in GitHub repository, execute this command: "git push -u origin main".

Setting Up Python Virtual Environment

This section covers how to set up a virtual environment for Python development.

Installing Python

  • Go to the python website and download the latest version of python.
  • Check on "add python to path" before starting installation.

Setting Up Virtual Environment

  • Create a folder for virtual environment installation.
  • Run command "python -m venv env_name" (replace env_name with desired name).
  • Activate virtual environment by running "env_nameScriptsactivate".
  • Install any package or library in this particular environment.

Enabling Scripts Running in Powershell

This section covers how to enable scripts running in Powershell if they have been disabled.

Steps for Enabling Scripts Running

  • Copy link from error message indicating that scripts cannot be loaded because running scripts is disabled on system.
  • Open link in browser where instructions will appear on how to enable scripts running in Powershell.
  • Scroll down and copy command to enable scripts running in Powershell.
  • Run the command in your terminal or directly in your Powershell command prompt.

Green Name Error

In this section, the speaker explains what the "green name" error means and how to fix it.

Understanding the Green Name Error

  • The green name error indicates that you are outside of your virtual environment.
  • This means that if you try to run a command that requires a library installed in your virtual environment, it will not work.

Fixing the Green Name Error

  • To fix the green name error, you need to activate your virtual environment.
  • Once activated, you can rerun the freeze command to see which libraries are installed in your virtual environment.

Turn any video into a summary like this

YouTube links, meetings, lectures. With transcripts, search, and chat.

Video description

Hi, thanks for watching our tutorial about Python Environment. In this tutorial, we’ll walk you through the following: TIMESTAMPS 0:00 Intro 0:13 Install Docker 0:47 Install WSL Kernel 1:30 Install Visual Studio Code 1:46 Install Dev Containers 2:12 Create Docker Dev Environment (Local Directory) 4:34 Install Pip Docker Dev Environment 5:12 Create Docker Dev Environment (GitHub Repository) 6:04 Install Git 9:52 Install Python Locally Windows 11:44 Python Virtual Environment (venv Module) Docker: https://www.docker.com/ Python: https://www.python.org/ WSL kernel: https://learn.microsoft.com/en-us/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package Visual Studio Code: https://code.visualstudio.com/ Git: https://git-scm.com/download/win I'd like to mention that we do have a sponsor for this video and that is https://mystarlog.com and that will be great if you all can check them out using the link in the description section below and support the sponsors. I'll be using their services to store important information about this tutorials that you can access later. I will talk more about their services when I have to use it, so with that said let's go ahead and get started. I encourage you take the opportunity to select one of the mystarlog.com plans starting at $5 dollars monthly and save your relevant information about this course and others resources. CHECK OUT OUR OTHER VIDEOS https://www.youtube.com/watch?v=ye1Y6DTijEw https://www.youtube.com/watch?v=37VBPissR1I Check out our channel here: https://www.youtube.com/@mystarlog5767 Don’t forget to subscribe! FIND US AT https://mystarlog.com/ GET IN TOUCH Contact us on info@mystarlog.com FOLLOW US ON SOCIAL Get updates or reach out to Get updates on our Social Media Profiles! Twitter: https://twitter.com/mystarlog_com Facebook: https://facebook.com/profile.php?id=100088690672450 Linkedin: https://linkedin.com/company/mystarlog Reddit: https://reddit.com/user/mystarlog Instagram: https://instagram.com/mystarlog