Virtual environments create isolated Python environments so that you can install packages without affecting the global Python environment. To set up a virtual environment:
run all the commands below on the console or terminal
# Install virtualenv if you haven't already
pip install virtualenv

# Create a virtual environment in the current directory
virtualenv venv

# Activate the virtual environment
source venv/bin/activate # For Linux/Mac

# Now you can use pip without sudo and avoid the warning
pip install <package_name>