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: Mount A Remote SMB/CIFS/NFS Share as a Specific User

This function is useful in scenarios where a separate user account is needed to mount…

Puppet Client Server Lab Setup

Server # Setup client machine name sudo vim /etc/hosts ## Insert this line ## xx.xx.xx.xx…

Enable WinRM Remotely

Usage:enableWinRm 'RemoteServer' get-credential $remoteComputer='REMOTESERVER' $winRmPort=5985 $adminCredential=get-credential function enableWinRm($remoteComputer,$winRmPort=5985,$adminCredential){ function Check-NetConnection($computername,$port,$timeout=200,$verbose=$false) { $tcp = New-Object System.Net.Sockets.TcpClient;…
Other project: DragonCoin.com