Search code examples
pythongoogle-app-enginepywhois

how to use pywhois module in gae


I have problems when try to import pywhois module, i can import my own module but still have troubles when import pywhois. I moved the pywhois folder in my project folder domain, the screentshot is below: enter image description here

This is the import and calling statment below: import part:

from pywhois import *

calling part:

 w = whois('hackbo.com')
 self.response.out.write(w)

The problems is it will always throw a http 500 error, error text is below:

Traceback (most recent call last):
  File "/home/li/Desktop/google_appengine/google/appengine/ext/webapp/__init__.py", line 700, in __call__
    handler.get(*groups)
  File "/home/li/Desktop/google_appengine/domain/main.py", line 43, in get
    w = whois('hackbo.com')
  File "pywhois/__init__.py", line 12, in whois
    text = nic_client.whois_lookup(None, domain, 0)
  File "pywhois/whois.py", line 157, in whois_lookup
    result = self.whois(query_arg, nichost, flags)
  File "pywhois/whois.py", line 100, in whois
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
AttributeError: 'module' object has no attribute 'socket'

What is this error means? why i could import my own module but can not import pywhois?


Solution

  • Google App Engine doesn't support the socket module, which pywhois uses. It allows you to import socket, but it's an empty module.