Posted On April 26, 2019

Python: Package Installer for Python (PIP)

kimconnect 0 comments
blog.KimConnect.com >> Codes >> Python: Package Installer for Python (PIP)

This comes preinstalled with Python 3.4 or higher. Similar to the Microsoft PowerShell Gallery, Python.org maintains an index of approved and community packages that can be imported and installed using ‘Import-Module activedirectory’ – I mean ‘pip install <package_name>’.

# Check if PIP is installed
pip --version
# List Installed packages
pip list
# Find packages
pip search <package_name>
# Display information about a package
pip show --verbose <package_name>
# Install packages
pip install <something>
# Uninstall packages & leave the source code on server
pip uninstall <package_name>
# Remove packages from server
pip remove <package_name>

Best practice: freeze package versions for coding consistency and deployment predictability. This is working against the default behavior, where pip would install the latest version of named packages

# Setup requirements
pip install -r requirements.txt

# Set specific versions of modules for pip to include
camelcase==0.2.1
django==1.4.2

Instead of manually inputting the package versions, it’s often more convenient to capture working configurations and write it into the requirements.txt as a baseline.

pip freeze -r pipFreeze_$(date +"%Y%m%d%H%M").txt > requirements.txt

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Get NIC MTU’s of All Hyper-V Hosts in Domain/Forest

# listHyperVHostsInForests.ps1 # Version: 0.02 function listHyperVHostsInForests{ # Ensure that AD management module is available…

How to Install Selenium for Python on Windows or Linux

Windows # This error would occur if pip is not up to date PS C:\WINDOWS\system32>…

PowerShell: Windows 2016 Pristine Image

Desired Output Windows Server deployment should be made as seamless and efficient as possible. Here's…