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
  ERROR WHILE INSTALLING PLAYSOUND MODULE satwants33 2 1,043 Mar-23-2024, 12:50 PM
Last Post: Ritik2508
  TypeError: cannot pickle ‘_asyncio.Future’ object Abdul_Rafey 1 273 Mar-07-2024, 03:40 PM
Last Post: deanhystad
  using ctypes to use a dll in a python module dauriac 3 293 Mar-06-2024, 04:38 PM
Last Post: dauriac
  problem with memory_graph module akbarza 3 299 Mar-04-2024, 10:15 AM
Last Post: snippsat
  Installation module 'pyproj' QuentinR 1 229 Feb-28-2024, 10:00 AM
Last Post: snippsat
  importing variables from module 8376459 1 247 Feb-18-2024, 02:24 PM
Last Post: deanhystad
  how to pass a mongdb command to a module and execute it. cspower 0 277 Feb-03-2024, 09:54 PM
Last Post: cspower
  datetime module question jacksfrustration 10 1,608 Jan-12-2024, 04:54 AM
Last Post: deanhystad
  problem using coloeama module akbarza 3 515 Jan-08-2024, 07:31 AM
Last Post: akbarza
  error in class: TypeError: 'str' object is not callable akbarza 2 456 Dec-30-2023, 04:35 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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