Skip to content

Instantly share code, notes, and snippets.

@bencord0
Created November 30, 2012 20:12
Show Gist options
  • Save bencord0/4178282 to your computer and use it in GitHub Desktop.
Save bencord0/4178282 to your computer and use it in GitHub Desktop.
Requests should be part of the standard library.
try:
import requests
except ImportError:
def install_package(dep):
# If you don't have pip, you're screwed.
from pip.commands.install import InstallCommand
dep_l = [dep]
inst = InstallCommand()
opts, args = inst.parser.parse_args()
try:
inst.run(opts, dep_l).install([])
except OSError:
# No idea why, but $virtualenv/build/$package/setup.py is attempting to
# be run even though the package is already installed at this point.
pass
install_package('requests')
import requests
print requests.get("http://httpbin.org/ip").text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment