How to Install Python Packages?

Open a terminal or command prompt

Check that Python is installed with `python –version` or `python3 –version`

Check that pip is installed with `pip –version` or `pip3 –version`

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 package3`

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

On Windows, use `venvScriptsactivate`

On macOS or Linux, use `source venv/bin/activate`

Install packages inside the activated virtual environment

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

Use `pip list` to view installed packages

Use `pip show package_name` to view package details

Uninstall a package with `pip uninstall package_name`

Suggested for You

Trending Today