def package_in_pypi ( package ) : url = 'http://pypi.python.org/simple/%s' % package try : urllib . request . urlopen ( url ) return True except urllib . error . HTTPError as e : logger . debug ( "Package not found on pypi: %s" , e ) return False
python make pypi trusted site
Check whether the package is registered on pypi
def package_in_pypi(package):
    """Check whether the package is registered on pypi"""
    url = 'http://pypi.python.org/simple/%s' % package
    try:
        urllib.request.urlopen(url)
        return True
    except urllib.error.HTTPError as e:
        logger.debug("Package not found on pypi: %s", e)
        return False