mkapi
mkapi copied to clipboard
ValueError: Could not find object: <package_name>
I have installed mkapi
via pip
.
I am trying to use page mode
as per the documentation.
My mkdocs.yml
has
# multiple lines not here for brevity
nav:
- API: mkapi/api/wappdriver
plugins:
- mkapi:
src_dirs: ['wappdriver']
Here wappdriver is the name of my package.
The directory structure is like:
- mkdocs.yml
- setup.py
- wappdriver
- __init__.py
- module.py
- docs
- index.md
When I run mkdocs serve
I get the following error
INFO - Building documentation...
Traceback (most recent call last):
File "/home/linuxbrew/.linuxbrew/bin/mkdocs", line 8, in <module>
sys.exit(cli())
File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.9/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.9/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.9/site-packages/mkdocs/__main__.py", line 133, in serve_command
serve.serve(
File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 141, in serve
config = builder()
File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 136, in builder
build(config, live_server=live_server, dirty=dirty)
File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.9/site-packages/mkdocs/commands/build.py", line 236, in build
config = config['plugins'].run_event('config', config)
File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.9/site-packages/mkdocs/plugins.py", line 94, in run_event
result = method(item, **kwargs)
File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.9/site-packages/mkapi/plugins/mkdocs.py", line 50, in on_config
config, self.abs_api_paths = mkapi.plugins.api.create_nav(
File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.9/site-packages/mkapi/plugins/api.py", line 23, in create_nav
page[key], abs_api_paths_ = collect(
File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.9/site-packages/mkapi/plugins/api.py", line 47, in collect
module = get_module(package_path)
File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.9/site-packages/mkapi/core/module.py", line 96, in get_module
obj = get_object(name)
File "/home/linuxbrew/.linuxbrew/opt/[email protected]/lib/python3.9/site-packages/mkapi/core/object.py", line 39, in get_object
raise ValueError(f"Could not find object: {name}")
ValueError: Could not find object: wappdriver
Is my way of usage of page mode incorrect ? Could you please guide if so.
Many thanks for reading. Your help is most appreciated.
I'm having the same problem on readthedocs.org - does anyone have an idea how to resolve this? I'm assuming it's something with having correct paths set, but after trying all the options I could think of it is the same. Any help appreciated!
Over a year after my comment, I think I have figured out the issue.
The issue on Read the Docs was caused by the fact that my library was not installed, and their builder doesn't access the local packages; so the library in case needs to be installed alongside any other build dependencies. My original .readthedocs.yaml
had this configuration:
python:
install:
- requirements: docs/requirements.txt
This installed the dependencies, but not the actual library. Since pip
can now find the dependencies in pyproject.toml
, I have changed the configuration to:
python:
install:
- method: pip
path: .
extra_requirements:
- docs
In this version, the docs
is a set of dependencies defined in [project.optional-dependencies]
of pyproject.toml
; and the library gets installed along with them.
Another cause of the above error is when the path is incorrectly set in mkdocs.yaml
. I would dare to guess that @aahnik's example above doesn't need the src_dirs: ['wappdriver']
in its configuration, and that including it makes mkapi
to look for the code in wappdriver.wappdriver
; but I might be wrong.