PIP and Basic intoduction to python packages
PIP
Hello, In this video tutorial lets see what is pip so pip is python package managing system through which you can install python packages, packages are peices of scripts or codes which assist programmers in a way that they dont have to write tone of code to do simple tasks also because of packages, you dont have to learn each and everything because some body already has write down a code for you so you can just import that package in your code and use it, Isn't cool?
Now lets see that how you can install python package, open command prompt (CMD) and type
pip install <package_name>
and it will install in your code.
lets say you want to install package numpy, so type
pip install numpy
and then in your code, write
import numpy as np
now you can use numpy in your code,
Some packages are not just few lines of small scripts instead those are complete frameworks and requires other softwares to run e.g tensorflow require CUDA and CUDnn, and installation of those packages are not easy just through pip, so the best way is to google it or just follow along with my tutorials and I will try to cover most of the things so that you dont have to search.
OS & SYS Module
OS Module
Now lets see some basic python packages, In this tutorial I am just giving introduction but in next video I will try to cover most of the functions in os and sys modules.
First lets create a folder in same directory in which you put your code (.py) file.
Lets run a script
import os
os.makedirs("New Folder")
This snippet will create folder in same directory where you put your code. In the same way if you want to see that if the folder is already present in that directory so you can write
import os
os.makedirs()
if os.path.exists("New Folder"):
pass
#Do something
SYS Module
The sys module in python provides variousvariables and functions that are used to manipulate different parts of the python runtime environment. Lets do a simple example that how you can pass command line arguments to your script using sys module.
For that write following piece of script
import sys
print(f"My name is {sys.argv[1]} and I am {sys.argv[2]}")
Now open cmd in same directoy and type : python name_of_python_file.py Alex Datascientist
and script will print : My name is Alex and I am Datascientist.
Subscribe to my youtube channel
Complete Series
- Website Introduction, future plans and How to install python in your windows machine
- Variables in python
- Lists Tuples and Dictionaries in python (Datastructures)
- Python 3 Introduction to loops,try except block and functions
- Python 3 loops and functions in details
PIP and introduction to python essential packages
- Introduction to file handling in python