Skip to main content

Python PIP

 

Python PIP


What is PIP?

PIP is a package manager for Python packages, or modules if you like.

Note: If you have Python version 3.4 or later, PIP is included by default.


What is a Package?

A package contains all the files you need for a module.

Modules are Python code libraries you can include in your project.


Check if PIP is Installed

Navigate your command line to the location of Python's script directory, and type the following:

Example

Check PIP version:

C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>pip --version

Install PIP

If you do not have PIP installed, you can download and install it from this page: https://pypi.org/project/pip/


Download a Package

Downloading a package is very easy.

Open the command line interface and tell PIP to download the package you want.

Navigate your command line to the location of Python's script directory, and type the following:

Example

Download a package named "camelcase":

C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>pip install camelcase

Now you have downloaded and installed your first package!



Using a Package

Once the package is installed, it is ready to use.

Import the "camelcase" package into your project.

Example

Import and use "camelcase":

import camelcase

c = camelcase.CamelCase()

txt = "hello world"

print(c.hump(txt))


Find Packages

Find more packages at https://pypi.org/.


Remove a Package

Use the uninstall command to remove a package:

Example

Uninstall the package named "camelcase":

C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>pip uninstall camelcase

The PIP Package Manager will ask you to confirm that you want to remove the camelcase package:

Uninstalling camelcase-02.1:
  Would remove:
    c:\users\Your Name\appdata\local\programs\python\python36-32\lib\site-packages\camecase-0.2-py3.6.egg-info
    c:\users\Your Name\appdata\local\programs\python\python36-32\lib\site-packages\camecase\*
Proceed (y/n)?

Press y and the package will be removed.


List Packages

Use the list command to list all the packages installed on your system:

Example

List installed packages:

C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>pip list

Result:

Package         Version
-----------------------
camelcase       0.2
mysql-connector 2.1.6
pip             18.1
pymongo         3.6.1
setuptools      39.0.1

Comments

Popular posts from this blog

Python Math Module

  Python  Math Python has a set of built-in math functions, including an extensive math module, that allows you to perform mathematical tasks on numbers. Built-in Math Functions The  min()  and  max()  functions can be used to find the lowest or highest value in an iterable: Example x =  min ( 5 ,  10 ,  25 ) y =  max ( 5 ,  10 ,  25 ) print (x) print (y) The  abs()  function returns the absolute (positive) value of the specified number: Example x =  abs (- 7.25 ) print (x) The  pow( x ,  y )  function returns the value of x to the power of y (x y ). Example Return the value of 4 to the power of 3 (same as 4 * 4 * 4): x =  pow ( 4 ,  3 ) print (x) The Math Module Python has also a built-in module called  math , which extends the list of mathematical functions. To use it, you must import the  math  module: import  math When you have imported the  math  module,...

Python Loops

  While Loops Python Loops Python has two primitive loop commands: while  loops for  loops The while Loop With the  while  loop we can execute a set of statements as long as a condition is true. Example Print i as long as i is less than 6: i =  1 while  i <  6 :    print (i)   i +=  1 Note:  remember to increment i, or else the loop will continue forever. The  while  loop requires relevant variables to be ready, in this example we need to define an indexing variable,  i , which we set to 1. The break Statement With the  break  statement we can stop the loop even if the while condition is true: Example Exit the loop when i is 3: i =  1 while  i <  6 :    print (i)    if  i ==  3 :      break   i +=  1 The continue Statement With the  continue  statement we can stop the current iteration, and continue...

Python Lists

  Python  Lists mylist = [ "apple" ,  "banana" ,  "cherry" ] List Lists are used to store multiple items in a single variable. Lists are one of 4 built-in data types in Python used to store collections of data, the other 3 are  Tuple ,  Set , and  Dictionary , all with different qualities and usage. Lists are created using square brackets: Example Create a List: thislist = [ "apple" ,  "banana" ,  "cherry" ] print (thislist) List Items List items are ordered, changeable, and allow duplicate values. List items are indexed, the first item has index  [0] , the second item has index  [1]  etc. Ordered When we say that lists are ordered, it means that the items have a defined order, and that order will not change. If you add new items to a list, the new items will be placed at the end of the list. Changeable The list is changeable, meaning that we can change, add, and remove items in a list after it has been created. Allow Duplicat...