Python Forum
(TypeError: 'module' object is not callable) for getopt Module
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
(TypeError: 'module' object is not callable) for getopt Module
#1
I'm fairly new to python, and I have been trying to use the "getopt" module working in my script without success.

I troubleshoot, I removed all other code from my script and just worked with the code shown below. Working in the interactive shell, I have no problems getting output.


SCRIPT
--------------------------------------------------------
#!/usr/bin/python

import getopt

print getopt.getopt(['-a', '-bval', '-c', 'val'], 'ab:c:')
---------------
OUTPUT:
Traceback (most recent call last):
File "./test-getopt.py", line 3, in <module>
import getopt
File "/home/nnevarez/HTB/SCRIPTS/getopt.py", line 23, in <module>
#
TypeError: 'module' object is not callable





INTERACTIVE
-------------------------------------------------------
>>> import getopt
>>>
>>>
>>> print getopt.getopt(['-a', '-bval', '-c', 'val'], 'ab:c:')
([('-a', ''), ('-b', 'val'), ('-c', 'val')], [])
>>>
-------------------------------------------------------
Reply
#2
You have a file called "getopt.py". This is interfering with the module "getopt.py". Rename your file to something else.
Reply
#3
Thanks a lot! That did the trick.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  game sounds module Pedroski55 5 31 6 hours ago
Last Post: Pedroski55
  module not found error Pedroski55 15 178 Jun-10-2026, 05:41 PM
Last Post: noisefloor
Question [SOLVED] Recommended way to upgrade module? Winfried 3 67 Apr-19-2026, 11:57 AM
Last Post: noisefloor
  Pylance: "... is not a known attribute of module ..." ? MvGulik 5 3,663 Jul-08-2025, 04:41 PM
Last Post: MvGulik
  Dynamic Module Import Error DaddyMAN 3 1,642 Jun-20-2025, 12:07 AM
Last Post: Pedroski55
  Using moviepy fails due to "ModuleNotFoundError: No module named 'pip._internal.utils sheepog 2 2,478 May-28-2025, 06:57 PM
Last Post: sheepog
  ModuleNotFoundError: No module named 'eyed3' Wimpy_Wellington 3 5,231 May-10-2025, 05:56 PM
Last Post: Wimpy_Wellington
  ModuleNotFoundError: No module named 'tkcalendar', Thonny, Windows 10 Edward_ 4 6,422 Apr-06-2025, 07:56 PM
Last Post: Edward_
  personal module Azdaghost 3 1,587 Mar-30-2025, 08:40 PM
Last Post: deanhystad
  Merge htm files with shutil library (TypeError: 'module' object is not callable) Melcu54 7 4,943 Mar-09-2025, 04:25 PM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020