Skip to content

Instantly share code, notes, and snippets.

@prophile
Created March 8, 2014 22:14
Show Gist options
  • Select an option

  • Save prophile/9439745 to your computer and use it in GitHub Desktop.

Select an option

Save prophile/9439745 to your computer and use it in GitHub Desktop.
import subprocess
import sys
try:
policy = subprocess.check_output(['apt-cache', 'policy', 'python-dev'])
if 'Installed: (none)' in policy:
print("ERROR: no python dev package installed")
print("Please run: sudo apt-get install python-dev")
sys.exit(1)
except OSError:
try:
subprocess.check_output(['rpm', '-qi', 'python-devel'])
except subprocess.CalledProcessError:
print("ERROR: no python dev package installed")
print("Please run: sudo yum install python-devel")
except OSError:
print("NOTICE: OS detection failed, assuming Python dev packages")
print("If you see an error about Python.h, install your OS's python dev package")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment