Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: 'module' object is not callable Python3 [duplicate]

Hello i tried run the run.py but i got an error message!

Run.py

from modules import HTTPHeaders
site = "https://google.com"
HTTPHeaders(site, _verbose=True)

HTTPHeaders.py

import dns
import dns.resolver
def HTTPHeaders(site, _verbose=None):
if _verbose != None:
    try:
        r = http.request('GET', "http://"+site)
    except:
        pass

    if (r.status == 200):
        print("HTTP/1.1 200 OK")
    else:
        print(r.status)
    try:
        print("Content-Type : "+r.headers['Content-Type'])
    except:
        pass
    try:
        print("Server : "+r.headers['Server'])
    except:
        pass
    try:
        print("Set-Cookie : "+r.headers['Set-Cookie'])
    except:
        pass

My error :

    TypeError: 'module' object is not callable

How can i fix this error ? Thank you :)

like image 645
dada Avatar asked Nov 30 '25 08:11

dada


1 Answers

Try this:

from modules import HTTPHeaders
HTTPHeaders.HTTPHeaders(...)

You imported the module itself, so you have to access the function using the dot notation.

Alternatively import the function like this:

from modules.HTTPHeaders import HTTPHeaders
HTTPHeaders(...)
like image 154
sanitizedUser Avatar answered Dec 01 '25 22:12

sanitizedUser