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
  ModuleNotFoundError: No module named 'tkcalendar', Thonny, Windows 10 Edward_ 4 1,027 Apr-06-2025, 07:56 PM
Last Post: Edward_
  personal module Azdaghost 3 812 Mar-30-2025, 08:40 PM
Last Post: deanhystad
  Merge htm files with shutil library (TypeError: 'module' object is not callable) Melcu54 7 3,501 Mar-09-2025, 04:25 PM
Last Post: Pedroski55
  Upgraded Python: Module no longer found - for Linux Curbie 8 1,668 Mar-05-2025, 06:01 PM
Last Post: Curbie
  Python Module for PowerLED 2.89.4 ChonkyBork 3 730 Feb-14-2025, 01:21 AM
Last Post: ChonkyBork
  No module named 'importlib.metadata' EdVS 3 1,171 Jan-30-2025, 09:55 AM
Last Post: Larz60+
  problem with memory_graph module akbarza 5 1,823 Jan-14-2025, 04:31 PM
Last Post: Gribouillis
Question [SOLVED] Upgraded Python: Module no longer found Winfried 1 1,297 Jan-01-2025, 02:43 PM
Last Post: Larz60+
  Python 3.13(Windows) does not have the latest module OS phillip_from_oz 1 903 Dec-13-2024, 04:35 AM
Last Post: deanhystad
  Help on tkinter module upendra 8 2,091 Nov-10-2024, 03:14 PM
Last Post: menator01

Forum Jump:

User Panel Messages

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