reflex icon indicating copy to clipboard operation
reflex copied to clipboard

'module' object is not callable

Open reigadegr opened this issue 1 year ago β€’ 2 comments

Using command: reflex run --loglevel debug return this message: Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in run_code File "C:\Users\admxcy.conda\envs\py11\Scripts\reflex.exe_main.py", line 7, in File "C:\Users\admxcy.conda\envs\py11\Lib\site-packages\typer\main.py", line 326, in call raise e File "C:\Users\admxcy.conda\envs\py11\Lib\site-packages\typer\main.py", line 309, in call return get_command(self)(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\admxcy.conda\envs\py11\Lib\site-packages\click\core.py", line 1157, in call return self.main(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\admxcy.conda\envs\py11\Lib\site-packages\typer\core.py", line 723, in main return _main( ^^^^^^ File "C:\Users\admxcy.conda\envs\py11\Lib\site-packages\typer\core.py", line 193, in _main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "C:\Users\admxcy.conda\envs\py11\Lib\site-packages\click\core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\admxcy.conda\envs\py11\Lib\site-packages\click\core.py", line 1434, in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\admxcy.conda\envs\py11\Lib\site-packages\click\core.py", line 783, in invoke return __callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\admxcy.conda\envs\py11\Lib\site-packages\typer\main.py", line 692, in wrapper return callback(**use_params) ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\admxcy.conda\envs\py11\Lib\site-packages\reflex\reflex.py", line 260, in run _run(env, frontend, backend, frontend_port, backend_port, backend_host, loglevel) File "C:\Users\admxcy.conda\envs\py11\Lib\site-packages\reflex\reflex.py", line 186, in _run prerequisites.get_compiled_app() File "C:\Users\admxcy.conda\envs\py11\Lib\site-packages\reflex\utils\prerequisites.py", line 288, in get_compiled_app app_module = get_app(reload=reload) ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\admxcy.conda\envs\py11\Lib\site-packages\reflex\utils\prerequisites.py", line 261, in get_app app = import(module, fromlist=(constants.CompileVars.APP,)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\00shixi\yz_model_search\yz_model_search\yz_model_search.py", line 28, in app.add_page(index) File "C:\Users\admxcy.conda\envs\py11\Lib\site-packages\reflex\app.py", line 500, in add_page component = self._generate_component(component) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\admxcy.conda\envs\py11\Lib\site-packages\reflex\app.py", line 433, in _generate_component raise e File "C:\Users\admxcy.conda\envs\py11\Lib\site-packages\reflex\app.py", line 422, in _generate_component return component if isinstance(component, Component) else component() ^^^^^^^^^^^ File "E:\00shixi\yz_model_search\yz_model_search\yz_model_search.py", line 10, in index navbar(), ^^^^^^^^ TypeError: 'module' object is not callable can your tell me how to fix?

reigadegr avatar Jul 23 '24 06:07 reigadegr

Hey @reigadegr can you share the page or component where you are importing the Component? I believe what you are doing is importing the file and trying to call the file in add_page, instead of the Callable function.

For example, change this:

import reflex as rx
import create_part as create_part

app = rx.App()
app.add_page(create_part)

to

import reflex as rx
from create_part import create_part

app = rx.App()
app.add_page(create_part)

dapomeranz avatar Jul 23 '24 16:07 dapomeranz

I do think there could be better error handling here to warn people when/why this is happening. Not sure how often this comes up.

dapomeranz avatar Jul 23 '24 16:07 dapomeranz

works as expected

adhami3310 avatar Feb 05 '25 01:02 adhami3310