How to Install Packages in Python?

Open a terminal or command prompt

Check that Python and pip are installed

Install a package with `pip install package_name`

Install a specific version with `pip install package_name==version`

Upgrade a package with `pip install –upgrade package_name`

Install multiple packages with `pip install package1 package2`

Install from a requirements file with `pip install -r requirements.txt`

Use a virtual environment with `python -m venv venv`

Activate the virtual environment before installing packages

Use `python -m pip install package_name` if `pip` is not recognized

Use `pip3 install package_name` if your system requires Python 3 explicitly

Verify installation with `pip show package_name`

List installed packages with `pip list`

Suggested for You

Trending Today