CodeGym /Courses /Python SELF EN /Package Managers

Package Managers

Python SELF EN
Level 19 , Lesson 2
Available

3.1 Introduction to Package Managers

Package managers in Python are important tools for managing dependencies and packages in projects. They make it easier to install, update, remove, and manage packages and libraries, providing convenience and efficiency in development.

As of today, there are 4 popular package managers for Python:

  • pip
  • conda
  • pipenv
  • poetry

Starting with Python 3.4, the package manager pip, which stands for Python Package Installer, is installed with it. Today, pip is the standard package manager for Python. It's used for installing and managing packages distributed via the Python Package Index (PyPI).

Installing pip

pip is usually installed with Python. You can check if pip is installed using the following command:


pip --version

If pip is not installed, you can manually install it by downloading get-pip.py and running it in Terminal:


curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py

curl is a command-line tool for transferring data using various protocols. It's often used for downloading files, sending data to a server, testing APIs, and more. In this case, we're using it for downloading.

Important! On most macOS systems, if you're using Terminal to run Python 3, you use the commands python3 and pip3, and python and pip might not be available by default. In that case, to check for Python and pip on the system, you need to use these commands:


python3 --version
pip3 --version

And from now on, use pip3 instead of pip, python3 instead of python. If you want, you can fix this in the configuration files.

3.2 Basic pip Commands

Installing a package


pip install package_name

Installing a specific version of a package


pip install package_name==1.0.0

Updating a package


pip install --upgrade package_name

Removing a package


pip uninstall package_name
List of installed packages

pip list

Some operations, like uninstalling, require confirmation (Y/n). In that case, just press the corresponding key on your keyboard. Additionally, you can use the flag


-y

in the command to agree to the action right away:


pip uninstall -y package_name

Example of using pip


pip install requests
pip install numpy==1.21.0
pip list
pip uninstall -y requests

3.3 Package Manager conda

conda is a package manager and environment management system that is used for installing and managing packages not just for Python, but for other programming languages as well. It's particularly popular in scientific and analytical communities due to its ability to manage dependencies and create isolated environments.

Installing conda

conda comes with the Anaconda and Miniconda distributions. You can install Anaconda or Miniconda by downloading them from the official website:

  • Anaconda
  • Miniconda
Official Website

Basic conda Commands

Creating a new environment


conda create --name myenv

Activating an environment


conda activate myenv

Deactivating an environment


conda deactivate

Installing a package


conda install package_name

Installing a package from a specific channel


conda install -c conda-forge package_name

List of installed packages


conda list

Example of using conda


conda create --name myenv
conda activate myenv
conda install numpy
conda list
conda deactivate

I think two package managers are enough for now. It'll be a few months before you run out of things to do with them.

2
Task
Python SELF EN, level 19, lesson 2
Locked
Installing packages using pip
Installing packages using pip
2
Task
Python SELF EN, level 19, lesson 2
Locked
Creating and Managing Environments with Conda
Creating and Managing Environments with Conda
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION