Python-for-Automation/C2/Setup-Python-Environment-for-Automation/English

From Script | Spoken-Tutorial
Revision as of 17:43, 18 December 2024 by Nirmala Venkat (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Visual Cue Narration
Show slide:

Welcome

Welcome to the Spoken Tutorial on " Setup Python environment for Automation ".
Show slide:

Learning Objectives

In this tutorial, we will learn how to
  • Install Python 3.12.3 in Ubuntu and Windows OS.
  • Create a Virtual environment
  • Install necessary libraries required for automation.
Show slide:

System Requirements

To record this tutorial, I am using
  • Ubuntu Linux OS version 22.04 and
  • Windows 11
Show slide:

Prerequisite

To follow this tutorial you must have basic knowledge of using
  • Linux Terminal
  • Windows command prompt
  • Python
  • For pre-requisite Linux and Python tutorials, please visit this website.
Show slide:

Code files

  • The files used in this tutorial are provided in the Code files link.
  • Please download and extract the files.
  • Make a copy and then use them while practicing.
Show slide:

Automation

  • Automation is the use of technology to perform tasks with minimal human intervention.
  • It automates repetitive tasks to save time and reduce errors.
  • It provides uniformity in operations and saves time.

Point to the files in the downloads folder

Open Python_installation_linux.txt

Open packages.txt and show

I have created Python_installation_linux.txt and packages.txt files for installation.

Python_installation_linux.txt file has the list of commands to install python 3.12.3.

You may copy and paste these commands in the terminal instead of typing.

Remember to Press the Enter key after each command in the terminal.

packages.txt file contains the library names used in the Python for Automation series.

Press Ctrl, Alt and T keys

Now let us open the terminal window by pressing Ctrl, Alt and T keys together.
>Type sudo apt update

Press enter

Now type sudo space apt space update and press Enter.

This command refreshes the local package index with the latest repository data.

>Type python3 --version

Press enter

Next type python3 space hyphen hyphen version.

You can see the version of python in your system.

Highlight Python 3.12.3 Here it is python 3.12.3
Only narration

Highlight Python 3.12.3

The python version varies based on the Ubuntu Linux version.

We will create a virtual environment and install the python and required libraries.

If your python version is 3.12 or higher proceed with the following steps: If not, move to the second half of this tutorial.

>Type sudo apt install build-essential libssl-dev libffi-dev python3-dev Type the command as shown.

This command installs additional packages and tools.

>Type sudo apt install -y python3-pip
Type the command as shown.
We install pip to manage Python packages and libraries for our projects.

>Type sudo apt install -y python3-venv

Then press enter.

Type the command as shown.

Virtual environments provide isolated Python project spaces on your server.

>Type python3.12 -m venv Automation

Then press enter.

Type python3 dot 12 space hyphen m space venv space Automation
You can create a new environment with the name Automation.
>Type source Automation/bin/activate

Then press enter.

To activate the environment, type the command as shown.
We can see the name “Automation” in the command prompt.
>Type sudo apt-get install espeak python3-tk default-jre Type the command as shown to install few necessary software packages for our Automation tutorial.

>Type cd Downloads

Now, we need to install the libraries required for this python for Automation series.

I have already downloaded packages.txt in my Downloads folder.

Go to the Downloads directory by typing cd space Downloads.

>Typepip3 install -r packages.txt

Now type pip3 space install space hyphen r space packages.txt

Through this command, we can install the necessary libraries.

Highlight the output We can see that all our libraries are installed.
Only narration

>Type deactivate

We can exit the virtual environment with the command : deactivate
If your python version is lower than 3.12, we will see how to install python 3.12.3
Type the command as shown

Hyphen y automatically answers "yes" to prompts in the terminal window.

Download python 3.12.3>cd /usr/src

Type “cd space forward slash usr forward slash src

This command navigates the directory to install Python from the source.

> sudo curl -O

Next we will type the command to install python3.12.3 as shown.
Hyphen capital O represents remote file output.
This is the URL from which python is downloaded.

Extract archive>sudo tar xzf Python-3.12.3.tgz

To unpack the downloaded file, type the command as shown

Compile and install

>cd Python-3.12.3

Now we navigate to the extracted directory.
Type
cd space Python hyphen 3 dot 12 dot 3
It changes the directory to the extracted Python source.
>sudo ./configure --enable-optimizations
Now let us configure the build and install python.
Type the command as shown
This command prepares the build system with optimizations.
>sudo make -j $(nproc)

Highlight make -j $(nproc)

Type the command as shown.
This command compiles the source code using all available CPU cores.
>sudo make altinstall

Highlight make altinstall

Type sudo space make space altinstall

This command make altinstall install Python without overwriting the default Python binary.

Verify python version: python3.12 --version

Let us verify the python version that has been installed,

Type

python3 dot 12 space hyphen hyphen version.

Highlight the successful installation.

Now we can see that our python version 3.12.3 is Successfully installed.

>Type cd

Type cd and press enter to reset the directory.

>Type sudo apt install -y python3-pip

Then press enter.

Type sudo space apt space install space hyphen y space python3 hyphen pip

We install pip to manage Python packages and libraries for our projects.

>Type sudo apt install -y python3-venv

Then press enter.

Now let us proceed with creating a Virtual Environment.
Type the command as shown.

Virtual environments provide isolated Python project spaces on your server.

>Type sudo python3.12 -m venv Automation Type python3 dot 12 space hyphen m space venv space Automation

>Type source Automation/bin/activate

Then press enter.

Highlight Automation

To activate the environment

Type source space Automation forward slash bin forward slash activate

We can see the name “Automation” in the command prompt.

>Type sudo apt-get install espeak python3-tk default-jre Type the command as shown to install few necessary software packages for our Automation tutorial.

>Type cd Downloads

Now, we need to install the libraries required for this python for Automation series.

I have already downloaded packages.txt in my Downloads folder.

Go to the Downloads directory by typing cd space Downloads.

pip3 install -r packages.txt Now type pip3 space install space hyphen r space packages.txt

Through this command, we could install the necessary libraries.

Highlight the output We can see that all our libraries are installed.
Only narration

>Type deactivate

Once the work is done we can exit the virtual environment with the command : deactivate
Next let us install python on the Windows platform.
To download in windows


Show browser window

Open your web browser and go to the Python official website atpython.org.
Hover over the Downloads section. Hover over the Downloads section.
In the Downloads, select the Windows option In the Downloads section, select the Windows option
Scroll down.Under “Python 3.12.3 - April 9, 2024


Click on the "Download Windows installer (64-bit)" button below Downloads for windows .

Automatically the installer is downloaded.

Go to Downloads folder

Locate and double click on python-3.12.3-amd64 installer

Go to your Downloads folder.

Locate the file python-3.12.3-amd64 and double click on it to run the installer.

Click the Add Python.exe to PATH" at the bottom. Make sure to check the box at the bottom that says "Add Python.exe to PATH" at the bottom.
Click Install Now Click on "Install Now".
Complete installation Follow the prompts until the installation is complete.This might take some time.
Click the close button. Then click on the Close button at the bottom right side.
Show Command Prompt

Type python --version

Highlight python 3.12.3

Open the Command Prompt by pressing the Windows key.

Type "cmd", and press Enter.

Type python space hyphen hyphen version and press Enter.

We can see the python version here.

Show browser window

cd Downloads

Now, we need to install the libraries required for this python for Automation series.

I have already downloaded packages.txt in my Downloads folder.

Go to the Downloads directory by typing cd space Downloads in the command prompt.

Show Command Prompt

pip install -r packages.txt

Then, type pip space install space hyphen r space packages dot txt and press Enter.

This command installs all the libraries listed in the packages.txt file.

Show Command Prompt

pip list

Highlight Output

To verify that the libraries were installed successfully,

Type,

pip space list and press Enter.

You should see a list of installed libraries.

Show slide: This brings us to the end of the tutorial. Let us summarize.

In this tutorial, we have learnt to

  • Install Python 3.12.3 in Ubuntu and Windows OS.
  • Create a Virtual environment
  • Install necessary libraries required for automation.

Show slide:

About the Spoken Tutorial Project

The video at the following link summarizes the Spoken Tutorial project.

Please download and watch it.

Show Slide:

Spoken Tutorial Workshops

The Spoken Tutorial Project team conducts workshops and gives certificates.

For more details, please write to us.

Show Slide:

Answers for THIS Spoken Tutorial

*
Do you have questions in THIS Spoken Tutorial?
  • Please visit this site.
  • Choose the minute and second where you have the question
  • Explain your question briefly
  • The Spoken Tutorial project will ensure an answer
  • You will have to register to ask questions

Slide : Forum for specific questions

  • The Spoken Tutorial forum is for specific questions on this tutorial.
  • Please do not post unrelated and general questions on them.
  • This will help reduce the clutter.
  • With less clutter, we can use these discussions as instructional material.
show Slide:

FOSSEE Forum

For any general or technical questions on Python for

Automation, visit the FOSSEE forum and post your question.

Show slide

Acknowledgement

Spoken Tutorial Project was established by the Ministry of Education, Government of India.

Show slide

Thank You

This is Dhaarani Pushpam S, a FOSSEE Semester long intern 2024, IIT Bombay signing off.


Thanks for joining.

Contributors and Content Editors

Nirmala Venkat