code: 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
docs: Check whether the package is registered on pypi