Why i'm getting `TypeError: 'module' object is not callable`?
See original GitHub issueThis is my main.py
.
.
.
.
try:
cmd_type = sys.argv[1]
except IndexError:
cmd_type = "run"
if cmd_type == "manage":
call_command(*sys.argv[2:])
elif cmd_type == "run":
call_command("runserver")
.
.
.
Here i ran command to see my migrations for django app built by shiv even this command exited successfully but with that TypeError
i cannot use exit code of command. what am i missing? or what can i do to handle that?
shiv on shiv [$?] via shiv
[I] ➜ ./myapp-1.6.3-3a380acb.pyz manage showmigrations auth
auth
[X] 0001_initial
[X] 0002_alter_permission_name_max_length
[X] 0003_alter_user_email_max_length
[X] 0004_alter_user_username_opts
[X] 0005_alter_user_last_login_null
[X] 0006_require_contenttypes_0002
[X] 0007_alter_validators_add_error_messages
[X] 0008_alter_user_username_max_length
[X] 0009_alter_user_last_name_max_length
[X] 0010_alter_group_name_max_length
[X] 0011_update_proxy_permissions
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "./myapp-1.6.3-3a380acb.pyz/__main__.py", line 3, in <module>
File "./myapp-1.6.3-3a380acb.pyz/_bootstrap/__init__.py", line 179, in bootstrap
File "./myapp-1.6.3-3a380acb.pyz/_bootstrap/__init__.py", line 33, in run
TypeError: 'module' object is not callable
shiv on shiv [$?] via shiv
[I] ➜ echo $?
1
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
TypeError: 'module' object is not callable - Stack Overflow
It says module object is not callable , because your code is calling a module object. A module object is the type of...
Read more >TypeError: module object is not callable [Python Error Solved]
To put it simply, the "TypeError: 'module' object is not callable" error means that modules cannot be called like functions or methods. How...
Read more >What is "typeerror: 'module' object is not callable"
This error statement TypeError: 'module' object is not callable is raised as you are being confused about the Class name and Module name....
Read more >Typeerror module object is not callable : How to Fix?
Typeerror module object is not callable (Solution): ... The Golden rule to fix this error is to invoke the respective python class or...
Read more >TypeError: 'module' object is not callable in Python | bobbyhadz
The Python "TypeError: 'module' object is not callable" occurs when we import a module as import some_module but try to call it as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @yzdann, thanks this is helpful.
I think the crux of your issue is on the last line of your
build.sh
script, where you invokeshiv
:The string you pass to
-e
must be callable, and the snippet you show ofmain.py
indicates it’s a script, e.g. something you would run likepython3 ./myapp/main.py
. If your application defines anyconsole_script
(doc) entries you can use the-c
argument.All you need to do is sequester the runnable logic in
main.py
into a function. So, if your script is:Change it to:
And then change the string you pass to
-e
to bemyapp.main:cli
.Let me know if that helps!
All possible working solution at [Solved] TypeError: ‘module’ object is not callable