Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python3
packages
pip
community creator

Installation & uninstallation of packages in Python

K PARAM JOSHI

Package

All the files needed for a module are contained in a package.

  • Packages are installed based on the project requirement.
  • Before you install packages, check if PIP is installed – if it’s not installed, download PIP.

PIP is a package manager for Python packages or modules.

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

How to check the PIP version

Go to command prompt and navigate to the Python directory as shown:

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

Note: This is C:\Users\Your Name\AppData\Local\Programs\Python\Python36\Scripts Python directory in our case.

svg viewer

How to download a package

  1. Go to the command prompt.
  2. Navigate to the Python Scripts directory(as shown above).
  3. Now type:
pip install package-name

Example: C:\Users\Your Name\AppData\Local\Programs\Python\Python36\Scripts>pip install matplotlib

How to remove a package

  • Use uninstall to remove the package.

Example: C:\Users\Your Name\AppData\Local\Programs\Python\Python36\Scripts>pip uninstall matplotlib

  • It will ask whether to remove the package or not (y/n?) for confirmation.
  • y is for removing.
  • n is for not removing.

Packages list

To check all the packages in Python, use the pip list command.

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

  • List of installed packages will be displayed.

The same process is repeated for all the packages.

Code

Now, let’s try some of the previously mentioned commands in the widget below:

  1. Press the run button.
  2. The console will appear in the current Python directory.
  3. Try running commands. Example: pip --version

RELATED TAGS

python3
packages
pip
community creator
RELATED COURSES

View all Courses

Keep Exploring