Difference between revisions of "Python-for-Automation/C2/Setup-Python-Environment-for-Automation/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 1: Line 1:
  
<div style="margin-left:1.27cm;margin-right:0cm;"></div>
+
 
 
{| border="1"
 
{| border="1"
 
|-
 
|-
Line 6: Line 6:
 
|| '''Narration'''
 
|| '''Narration'''
 
|-
 
|-
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
 
 
|| Show slide:  
 
|| Show slide:  
  
 
'''Welcome'''
 
'''Welcome'''
|| Welcome to the Spoken Tutorial on '''" Setup Python environment for Automation ".'''
+
|| Welcome to the Spoken Tutorial on ''' Setup Python environment for Automation'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:  
 
|| Show slide:  
  
 
'''Learning Objectives'''
 
'''Learning Objectives'''
|| In this tutorial, we will learn how to  
+
|| In this tutorial, we will learn how to,
  
 
* Install''' Python 3.12.3 '''in''' Ubuntu''' and '''Windows OS.'''
 
* Install''' Python 3.12.3 '''in''' Ubuntu''' and '''Windows OS.'''
Line 21: Line 21:
 
* Install necessary libraries required for automation.
 
* Install necessary libraries required for automation.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:  
 
|| Show slide:  
  
Line 29: Line 29:
 
* '''Windows 11'''
 
* '''Windows 11'''
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:  
 
|| Show slide:  
  
Line 39: Line 39:
 
* '''Python'''
 
* '''Python'''
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
||  
+
|| Show slide:
 +
 
 +
'''Prerequisite'''
 
||  
 
||  
 
* For pre-requisite '''Linux''' and '''Python''' tutorials, please visit this website.
 
* For pre-requisite '''Linux''' and '''Python''' tutorials, please visit this website.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:
 
|| Show slide:
  
 
'''Code files'''
 
'''Code files'''
 
||
 
||
* <div style="margin-left:1.27cm;margin-right:0cm;">The files used in this tutorial are provided in the '''Code files''' link.</div>
+
* The files used in this tutorial are provided in the '''Code files''' link.
* <div style="margin-left:1.27cm;margin-right:0cm;">Please download and extract the files.</div>
+
* Please download and extract the files.
* <div style="margin-left:1.27cm;margin-right:0cm;">Make a copy and then use them while practicing.</div>
+
* Make a copy and then use them while practicing.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:  
 
|| Show slide:  
  
 
'''Automation '''
 
'''Automation '''
 
||  
 
||  
* <div style="margin-left:1.27cm;margin-right:0cm;">Automation is the use of technology to perform tasks with minimal human intervention.</div>
+
* Automation is the use of technology to perform tasks with minimal human intervention.
* <div style="margin-left:1.27cm;margin-right:0cm;">It automates repetitive tasks to save time and reduce errors.</div>
+
* It automates repetitive tasks to save time and reduce errors.
* <div style="margin-left:1.27cm;margin-right:0cm;">It provides uniformity in operations and saves time.</div>
+
* It provides uniformity in operations and saves time.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
||  
+
|| Point to the files in the downloads folder
 
+
Point to the files in the downloads folder
+
  
 
Open '''Python_installation_linux.txt'''  
 
Open '''Python_installation_linux.txt'''  
Line 79: Line 79:
  
 
'''packages.txt '''file contains the library names used in the Python for Automation series.
 
'''packages.txt '''file contains the library names used in the Python for Automation series.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
||  
+
|| Press '''Ctrl''', '''Alt''' and '''T keys'''.
 
+
|| Now let us open the terminal window by pressing ''Ctrl''', '''Alt''' and '''T keys''' together.
'''Press <span style="background-color:#ffffff;">Ctrl, Alt and T keys'''</span>
+
|-  
|| <span style="background-color:#ffffff;">Now let us open the terminal window by pressing&nbsp;</span><span style="background-color:#ffffff;">'''Ctrl, </span><span style="background-color:#ffffff;">Alt and T keys'''</span><span style="background-color:#ffffff;">&nbsp;together.</span>
+
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
 
|| '''>'''Type '''sudo apt update'''
 
|| '''>'''Type '''sudo apt update'''
  
Press enter
+
Press Enter
 
|| Now type '''sudo space apt space update '''and press '''Enter.'''
 
|| Now type '''sudo space apt space update '''and press '''Enter.'''
  
 
This command refreshes the local package index with the latest repository data.
 
This command refreshes the local package index with the latest repository data.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
||  
+
||   '''>'''Type '''python3 --version '''
 
+
'''>'''Type '''python3 --version '''
+
  
Press enter
+
Press Enter.
 
|| Next type '''python3 space hyphen hyphen version.'''
 
|| Next type '''python3 space hyphen hyphen version.'''
  
 
You can see the version of python in your system.
 
You can see the version of python in your system.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight '''Python 3.12.3'''
 
|| Highlight '''Python 3.12.3'''
 
|| Here it is '''python 3.12.3'''
 
|| Here it is '''python 3.12.3'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Only narration
 
|| Only narration
  
Line 112: Line 108:
  
 
If your '''python version''' is''' 3.12''' or higher proceed with the following steps: If not, move to the second half of this tutorial.
 
If your '''python version''' is''' 3.12''' or higher proceed with the following steps: If not, move to the second half of this tutorial.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| '''>'''Type '''sudo apt install build-essential libssl-dev libffi-dev python3-dev'''
 
|| '''>'''Type '''sudo apt install build-essential libssl-dev libffi-dev python3-dev'''
 
|| Type the command as shown.
 
|| Type the command as shown.
  
<span style="background-color:#ffffff;">This command </span>installs additional packages and tools.
+
This command installs additional packages and tools.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| '''>'''Type '''sudo apt install -y python3-pip'''
 
|| '''>'''Type '''sudo apt install -y python3-pip'''
 +
|| Type the command as shown.
  
|| <div style="color:#000000;">Type the command as shown.</div>
+
We install pip to manage Python packages and libraries for our projects.
 +
|-
 +
||  '''>'''Type '''sudo apt install -y python3-venv'''
  
<div style="color:#000000;">We install pip to manage Python packages and libraries for our projects.</div>
+
Then press Enter.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|| Type the command as shown.
||
+
 
+
'''>'''Type '''sudo apt install -y python3-venv'''
+
 
+
Then press enter.
+
|| <div style="color:#000000;">Type the command as shown.</div>
+
  
 
Virtual environments provide isolated Python project spaces on your server.
 
Virtual environments provide isolated Python project spaces on your server.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
||  
+
|| '''>'''Type '''python3.12 -m venv Automation'''
  
'''>'''Type '''python3.12 -m venv Automation'''
+
Then press Enter.
 +
|| Type '''python3 dot 12 space hyphen m space venv space Automation'''
  
Then press enter.
+
You can create a new environment with the name '''Automation.'''
|| <div style="color:#000000;">Type '''python3 dot 12 space hyphen m space venv space Automation'''</div>
+
|-  
 
+
<div style="color:#000000;">You can create a new environment with the name '''Automation.'''</div>
+
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
 
|| '''>'''Type '''source Automation/bin/activate'''
 
|| '''>'''Type '''source Automation/bin/activate'''
  
Then press enter.
+
Then press Enter.
|| <div style="color:#000000;">To activate the environment, type the command as shown.</div>
+
|| To activate the environment, type the command as shown.
  
<div style="color:#000000;">We can see the name “Automation” in the command prompt.</div>
+
We can see the name “Automation” in the command prompt.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
|| <span style="background-color:#ffffff;">'''>'''</span>Type '''sudo apt-get install espeak python3-tk default-jre'''
+
|| '''>'''Type '''sudo apt-get install espeak python3-tk default-jre'''
| style="color:#000000;" | Type the command as shown to install few necessary software packages for our Automation tutorial.
+
|| Type the command as shown to install few necessary software packages for our Automation tutorial.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
|| <div style="color:#ff0000;"></div>
+
|| '''>'''Type '''cd Downloads'''
 
+
|| Now, we need to&nbsp;'''install&nbsp;'''the libraries required for this python for Automation series.
<span style="background-color:#ffffff;">'''>'''</span>Type '''cd Downloads'''
+
|| <span style="background-color:#ffffff;">Now, we need to&nbsp;</span><span style="background-color:#ffffff;">'''install&nbsp;'''</span><span style="background-color:#ffffff;">the libraries required for this python for Automation series.</span>
+
  
 
I have already downloaded '''packages.txt '''in my '''Downloads f'''older.
 
I have already downloaded '''packages.txt '''in my '''Downloads f'''older.
  
 
Go to the '''Downloads '''directory by typing '''cd space Downloads.'''
 
Go to the '''Downloads '''directory by typing '''cd space Downloads.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
||  
+
|| '''>'''Type'''pip3 install -r packages.txt'''
 
+
'''>'''Type'''pip3 install -r packages.txt'''
+
 
|| Now type '''pip3 space install space hyphen r space packages.txt'''
 
|| Now type '''pip3 space install space hyphen r space packages.txt'''
  
 
Through this command, we can install the necessary libraries.
 
Through this command, we can install the necessary libraries.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight the output
 
|| Highlight the output
|| We can see that all our <span style="background-color:#ffffff;">libraries</span> are installed.
+
|| We can see that all our libraries are installed.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Only narration
 
|| Only narration
  
 
>Type deactivate
 
>Type deactivate
 
|| We can exit the virtual environment with the command : '''deactivate'''
 
|| We can exit the virtual environment with the command : '''deactivate'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
||  
+
|| Point point to the python version on the terminal.
 
|| If your '''python version''' is lower than '''3.12''', we will see how to install '''python 3.12.3'''
 
|| If your '''python version''' is lower than '''3.12''', we will see how to install '''python 3.12.3'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
||  
+
|| Point to the command.
 
|| Type the command as shown
 
|| Type the command as shown
  
 
'''Hyphen y '''automatically answers''' '''"yes" to prompts in the terminal window.
 
'''Hyphen y '''automatically answers''' '''"yes" to prompts in the terminal window.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
||  
+
|| Download python 3.12.3>'''cd /usr/src'''
 
+
Download python 3.12.3>'''cd /usr/src'''
+
 
+
 
|| Type '''“cd space forward slash usr forward slash src'''
 
|| Type '''“cd space forward slash usr forward slash src'''
  
 
This command navigates the directory to install '''Python''' from the source.
 
This command navigates the directory to install '''Python''' from the source.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
||  
+
||  '''> sudo curl -O '''
 +
|| Next we will type the command to install '''python3.12.3 '''as shown.
  
'''> sudo curl -O '''
+
'''Hyphen capital O''' represents remote file output.
  
|| <div style="color:#000000;"></div>
+
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
  
<div style="color:#000000;">Next we will type the command to install '''python3.12.3 '''as shown.</div>
+
|-  
 
+
|| Compile and install
<div style="color:#000000;">'''Hyphen capital O''' represents remote file output.</div>
+
 
+
<div style="color:#000000;">This is the URL from which '''python''' is downloaded.</div>
+
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
||  
+
 
+
Extract archive>'''sudo tar xzf Python-3.12.3.tgz'''
+
|| <div style="color:#000000;">To unpack the downloaded file, type the command as shown</div>
+
 
+
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
||
+
 
+
Compile and install
+
  
 
>'''cd Python-3.12.3'''
 
>'''cd Python-3.12.3'''
  
|| <div style="color:#000000;">Now we navigate to the extracted directory.</div>
+
|| Now we navigate to the extracted directory.
  
<div style="color:#000000;">Type</div>
+
Type
  
<div style="color:#000000;">'''cd space Python hyphen 3 dot 12 dot 3'''</div>
+
'''cd space Python hyphen 3 dot 12 dot 3'''
  
<div style="color:#000000;">It changes the directory to the extracted Python source.</div>
+
It changes the directory to the extracted Python source.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| '''>sudo ./configure --enable-optimizations'''
 
|| '''>sudo ./configure --enable-optimizations'''
|| <div style="color:#000000;">Now let us configure the build and install python.</div>
+
|| Now let us configure the build and install python.
  
<div style="color:#000000;">Type the command as shown</div>
+
Type the command as shown
  
<div style="color:#000000;">This command prepares the build system with optimizations.</div>
+
This command prepares the build system with optimizations.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| '''>sudo make -j $(nproc)'''
 
|| '''>sudo make -j $(nproc)'''
  
 
Highlight '''make -j $(nproc)'''
 
Highlight '''make -j $(nproc)'''
|| <div style="color:#000000;">Type the command as shown.</div>
+
|| Type the command as shown.
  
<div style="color:#000000;">This command compiles the source code using all available CPU cores.</div>
+
This command compiles the source code using all available CPU cores.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| '''>sudo make altinstall'''
 
|| '''>sudo make altinstall'''
  
Line 248: Line 223:
 
This command '''make altinstall '''install Python without overwriting the default '''Python''' binary.
 
This command '''make altinstall '''install Python without overwriting the default '''Python''' binary.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
||  
+
|| Verify python version: '''python3.12 --version'''
 
+
Verify python version: '''python3.12 --version'''
+
  
 
|| Let us verify the python version that has been installed,
 
|| Let us verify the python version that has been installed,
Line 258: Line 231:
  
 
'''python3 dot 12 space hyphen hyphen version'''.
 
'''python3 dot 12 space hyphen hyphen version'''.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
||  
+
|| Highlight the successful installation.
 
+
Highlight the successful installation.
+
 
|| Now we can see that our '''python version 3.12.3''' is Successfully installed.
 
|| Now we can see that our '''python version 3.12.3''' is Successfully installed.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
||  
+
||  '''>'''Type '''cd'''
 +
|| Type '''cd''' and press '''Enter''' to reset the directory.
 +
|-  
 +
|| '''>'''Type '''sudo apt install -y python3-pip'''
  
'''>'''Type '''cd'''
+
Then press Enter.
|| Type '''cd''' and press '''enter''' to reset the directory.
+
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
||
+
 
+
'''>'''Type '''sudo apt install -y python3-pip'''
+
 
+
Then press enter.
+
 
|| Type '''sudo space apt space install space hyphen y space python3 hyphen pip'''
 
|| 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.
 
We install pip to manage Python packages and libraries for our projects.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
|| <div style="color:#ff0000;"></div>
+
|| '''>'''Type '''sudo apt install -y python3-venv'''
  
'''>'''Type '''sudo apt install -y python3-venv'''
+
Then press Enter.
 +
|| Now let us proceed with creating a Virtual Environment.
  
Then press enter.
+
Type the command as shown.
|| <div style="color:#000000;">Now let us proceed with creating a Virtual Environment.</div>
+
 
+
<div style="color:#000000;">Type the command as shown.</div>
+
  
 
Virtual environments provide isolated Python project spaces on your server.
 
Virtual environments provide isolated Python project spaces on your server.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| '''>'''Type sudo '''python3.12 -m venv Automation'''
 
|| '''>'''Type sudo '''python3.12 -m venv Automation'''
  
 
|| Type '''python3 dot 12 space hyphen m space venv space Automation'''
 
|| Type '''python3 dot 12 space hyphen m space venv space Automation'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
|| <div style="color:#ff0000;"></div>
+
|| '''>'''Type '''source Automation/bin/activate'''
  
'''>'''Type '''source Automation/bin/activate'''
+
Then press Enter.
 
+
Then press enter.
+
  
 
Highlight Automation
 
Highlight Automation
Line 306: Line 269:
 
We can see the name “Automation” in the command prompt.
 
We can see the name “Automation” in the command prompt.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
|| <span style="background-color:#ffffff;">'''>'''</span>Type '''sudo apt-get install espeak python3-tk default-jre'''
+
|| '''>'''Type '''sudo apt-get install espeak python3-tk default-jre'''
| style="color:#000000;" | Type the command as shown to install few necessary software packages for our Automation tutorial.
+
|| Type the command as shown to install few necessary software packages for our Automation tutorial.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
||  
+
||  '''>'''Type'''&nbsp;cd Downloads'''
 +
|| Now, we need to&nbsp;'''install&nbsp;'''the libraries required for this python for Automation series.
  
<span style="background-color:#ffffff;">'''>'''</span>Type'''&nbsp;cd Downloads'''
+
I have already downloaded '''packages.txt '''in my '''Downloads '' folder.
 
+
|| <span style="background-color:#ffffff;">Now, we need to&nbsp;</span><span style="background-color:#ffffff;">'''install&nbsp;'''</span><span style="background-color:#ffffff;">the libraries required for this python for Automation series.</span>
+
 
+
I have already downloaded '''packages.txt '''in my '''Downloads f'''older.
+
  
 
Go to the '''Downloads '''directory by typing '''cd space Downloads.'''
 
Go to the '''Downloads '''directory by typing '''cd space Downloads.'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
|| <span style="background-color:#ffffff;">'''pip3 install -r packages.txt'''</span>
+
|| '''pip3 install -r packages.txt'''
 
+
 
|| Now type '''pip3 space install space hyphen r space packages.txt'''
 
|| Now type '''pip3 space install space hyphen r space packages.txt'''
  
 
Through this command, we could install the necessary libraries.
 
Through this command, we could install the necessary libraries.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Highlight the output
 
|| Highlight the output
|| We can see that all our <span style="background-color:#ffffff;">libraries</span> are installed.
+
|| We can see that all our libraries are installed.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Only narration
 
|| Only narration
  
<span style="background-color:#ffffff;">'''>'''</span><span style="background-color:#ffffff;">Type </span><span style="background-color:#ffffff;">'''deactivate'''</span>
+
'''>'''Type '''deactivate'''
 
|| Once the work is done we can exit the virtual environment with the command : '''deactivate'''
 
|| Once the work is done we can exit the virtual environment with the command : '''deactivate'''
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
|| <div style="color:#ff0000;"></div>
+
||  
 
+
<div style="color:#ff0000;"></div>
+
 
+
<div style="color:#ff0000;"></div>
+
 
+
 
|| Next let us install '''python''' on the '''Windows '''platform.
 
|| Next let us install '''python''' on the '''Windows '''platform.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| To download in windows
 
|| To download in windows
  
Line 348: Line 302:
 
Show browser window
 
Show browser window
 
|| Open your web browser and go to the '''Python''' official website at [https://www.python.org/  python.org].
 
|| Open your web browser and go to the '''Python''' official website at [https://www.python.org/  python.org].
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Hover over the '''Downloads''' section.  
 
|| Hover over the '''Downloads''' section.  
 
|| Hover over the '''Downloads''' section.
 
|| Hover over the '''Downloads''' section.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| In the '''Downloads''', select the '''Windows''' option
 
|| In the '''Downloads''', select the '''Windows''' option
 
|| In the '''Downloads section''', select the '''Windows''' option
 
|| In the '''Downloads section''', select the '''Windows''' option
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
||
+
||  Scroll down.
 +
 
 +
Scroll down.Under “[https://www.python.org/downloads/release/python-3123/ Python 3.12.3 - April 9, 2024]”'''
 +
 
 +
Click on the "'''Download [https://www.python.org/ftp/python/3.12.3/python-3.12.3-amd64.exe
 
|| Scroll down.Under “[https://www.python.org/downloads/release/python-3123/ Python 3.12.3 - April 9, 2024]”'''
 
|| Scroll down.Under “[https://www.python.org/downloads/release/python-3123/ Python 3.12.3 - April 9, 2024]”'''
  
Line 362: Line 320:
  
 
Automatically the installer is downloaded.
 
Automatically the installer is downloaded.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
|| Go to Downloads folder
+
|| Go to '''Downloads''' folder.
  
 
Locate and double click on '''python-3.12.3-amd64''' installer
 
Locate and double click on '''python-3.12.3-amd64''' installer
Line 370: Line 328:
  
 
Locate the file '''python-3.12.3-amd64''' and double click on it to run the installer.
 
Locate the file '''python-3.12.3-amd64''' and double click on it to run the installer.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Click the '''Add''' '''Python.exe''' '''to''' '''PATH'''" at the bottom.
 
|| 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.
 
|| Make sure to check the box at the bottom that says "'''Add''' '''Python.exe''' '''to''' '''PATH'''" at the bottom.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Click '''Install Now'''
 
|| Click '''Install Now'''
 
|| Click on "'''Install Now'''".
 
|| Click on "'''Install Now'''".
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Complete installation
 
|| Complete installation
 
|| Follow the prompts until the installation is complete.This might take some time.
 
|| Follow the prompts until the installation is complete.This might take some time.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Click the '''close '''button.
 
|| Click the '''close '''button.
 
|| Then click on the Close''' '''button at the bottom right side.
 
|| Then click on the Close''' '''button at the bottom right side.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show Command Prompt
 
|| Show Command Prompt
  
Line 396: Line 354:
 
We can see the python version here.
 
We can see the python version here.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show browser window
 
|| Show browser window
  
 
'''cd Downloads'''
 
'''cd Downloads'''
|| <span style="background-color:#ffffff;">Now, we need to&nbsp;</span><span style="background-color:#ffffff;">'''install&nbsp;'''</span><span style="background-color:#ffffff;">the libraries required for this python for Automation series.</span>
+
|| Now, we need to&nbsp;'''install&nbsp;'''the libraries required for this python for Automation series.
  
 
I have already downloaded '''packages.txt '''in my '''Downloads '''folder.
 
I have already downloaded '''packages.txt '''in my '''Downloads '''folder.
  
 
Go to the '''Downloads '''directory by typing '''cd space Downloads '''in the command prompt.
 
Go to the '''Downloads '''directory by typing '''cd space Downloads '''in the command prompt.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show Command Prompt
 
|| Show Command Prompt
  
Line 412: Line 370:
  
 
This command installs all the libraries listed in the '''packages.txt '''file.
 
This command installs all the libraries listed in the '''packages.txt '''file.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show Command Prompt
 
|| Show Command Prompt
  
Line 425: Line 383:
 
'''pip space list''' and press Enter.
 
'''pip space list''' and press Enter.
  
You should see a list of installed <span style="background-color:#ffffff;">libraries</span>.
+
You should see a list of installed libraries.
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
 
|| Show slide:  
 
|| Show slide:  
 
|| This brings us to the end of the tutorial. Let us summarize.
 
|| This brings us to the end of the tutorial. Let us summarize.
  
In this tutorial, we have learnt to
+
In this tutorial, we have learnt to,
* <div style="margin-left:1.27cm;margin-right:0cm;">Install''' Python 3.12.3 '''in''' Ubuntu''' and '''Windows OS.'''</div>
+
* Install''' Python 3.12.3 '''in''' Ubuntu''' and '''Windows OS.'''
* <div style="margin-left:1.27cm;margin-right:0cm;">Create a '''Virtual environment'''</div>
+
* Create a '''Virtual environment'''
* <div style="margin-left:1.27cm;margin-right:0cm;">Install necessary libraries required for automation.</div>
+
* Install necessary libraries required for automation.
  
|- style="border:1pt solid #000000;padding-top:0cm;padding-bottom:0cm;padding-left:0.206cm;padding-right:0.191cm;"
+
|-  
||  
+
|| Show slide:  
 
+
Show slide:  
+
  
 
'''About the Spoken Tutorial Project'''
 
'''About the Spoken Tutorial Project'''
|| <span style="background-color:#ffffff;">The video at the following link summarizes the </span><span style="background-color:#ffffff;">'''Spoken Tutorial project'''</span><span style="background-color:#ffffff;">.</span>
+
|| The video at the following link summarizes the '''Spoken Tutorial project'''.
  
 
Please download and watch it.
 
Please download and watch it.
 
|-
 
|-
| style="border-top:1pt solid #000000;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0cm;" |
+
||  Show Slide:
  
Show Slide:
+
'''Spoken Tutorial Workshops'''  
 
+
|| The '''Spoken Tutorial Project''' team conducts workshops and gives certificates.
<span style="background-color:#ffffff;">'''Spoken Tutorial Workshops'''</span>
+
| style="border:1pt solid #000000;padding:0cm;" | <span style="background-color:#ffffff;">The </span><span style="background-color:#ffffff;">'''Spoken Tutorial Project'''</span><span style="background-color:#ffffff;"> team conducts workshops and gives certificates.</span>
+
  
 
For more details, please write to us.
 
For more details, please write to us.
 
|-
 
|-
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0cm;" |  
+
|| Show Slide:
 
+
Show Slide:
+
  
 
'''Answers for THIS Spoken Tutorial'''
 
'''Answers for THIS Spoken Tutorial'''
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0cm;" | * <div style="margin-left:1.905cm;margin-right:0cm;">Do you have questions in THIS Spoken Tutorial?</div>
+
||  
* <div style="margin-left:1.905cm;margin-right:0cm;">Please visit this site.</div>
+
* Do you have questions in THIS Spoken Tutorial?
* <div style="margin-left:1.905cm;margin-right:0cm;">Choose the minute and second where you have the question</div>
+
* Please visit this site.
* <div style="margin-left:1.905cm;margin-right:0cm;">Explain your question briefly</div>
+
* Choose the minute and second where you have the question
* <div style="margin-left:1.905cm;margin-right:0cm;">The Spoken Tutorial project will ensure an answer</div>
+
* Explain your question briefly
* <div style="margin-left:1.905cm;margin-right:0cm;">You will have to register to ask questions</div>
+
* The Spoken Tutorial project will ensure an answer
 +
* You will have to register to ask questions
  
 
|-
 
|-
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0cm;" |
+
|| Show Slide:  
  
Slide : '''Forum for specific questions'''
+
'''Forum for specific questions'''
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0cm;" |
+
||
* <div style="margin-left:1.905cm;margin-right:0cm;">The Spoken Tutorial forum is for specific questions on this tutorial.</div>
+
* The Spoken Tutorial forum is for specific questions on this tutorial.
* <div style="margin-left:1.905cm;margin-right:0cm;">Please do not post unrelated and general questions on them.</div>
+
* Please do not post unrelated and general questions on them.
* <div style="margin-left:1.905cm;margin-right:0cm;">This will help reduce the clutter.</div>
+
* This will help reduce the clutter.
* <div style="margin-left:1.905cm;margin-right:0cm;">With less clutter, we can use these discussions as instructional material.</div>
+
* With less clutter, we can use these discussions as instructional material.
 
|-
 
|-
| style="border-top:1pt solid #000000;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0cm;" | <span style="background-color:#ffffff;">s</span><span style="background-color:#ffffff;">how Slide:</span>
+
|| show Slide:
  
 
'''FOSSEE Forum'''
 
'''FOSSEE Forum'''
| style="border:1pt solid #000000;padding:0cm;" | For any general or technical questions on '''Python for'''
+
|| For any general or technical questions on '''Python for'''
  
 
'''Automation''', visit the''' FOSSEE forum''' and post your question.
 
'''Automation''', visit the''' FOSSEE forum''' and post your question.
 
|-
 
|-
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0cm;" | Show slide
+
|| Show slide
  
 
'''Acknowledgement'''
 
'''Acknowledgement'''
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0cm;" | '''Spoken Tutorial''' Project was established by the '''Ministry of Education, Government of India'''.
+
|| '''Spoken Tutorial''' Project was established by the '''Ministry of Education, Government of India'''.
 
|-
 
|-
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:none;padding:0cm;" | <div style="color:#ff0000;"></div>
+
|| Show slide
 
+
Show slide
+
  
 
'''Thank You'''
 
'''Thank You'''
| style="border-top:none;border-bottom:1pt solid #000000;border-left:1pt solid #000000;border-right:1pt solid #000000;padding:0cm;" | <span style="background-color:#ffffff;">This is </span><span style="background-color:#ffffff;">'''Dhaarani Pushpam S, '''</span><span style="background-color:#ffffff;">a FOSSEE Semester long intern 2024, IIT Bombay signing off.</span>
+
|| This is '''Dhaarani Pushpam S, '''a FOSSEE Semester long intern 2024, IIT Bombay signing off.
 
+
  
 
Thanks for joining.
 
Thanks for joining.
 
|-
 
|-
 
|}
 
|}

Revision as of 15:09, 26 December 2024


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
Show slide:

Prerequisite

  • 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
Point point to the python version on the terminal. If your python version is lower than 3.12, we will see how to install python 3.12.3
Point to the command. 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 at python.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.

Scroll down.Under “Python 3.12.3 - April 9, 2024

Click on the "Download [https://www.python.org/ftp/python/3.12.3/python-3.12.3-amd64.exe

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
Show 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

Madhurig, Nirmala Venkat