Created
November 30, 2012 20:12
-
-
Save bencord0/4178282 to your computer and use it in GitHub Desktop.
Requests should be part of the standard library.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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