Reputation: 213
I am trying to use sphinx to run an autodoc. My project structure like this:
Where the python files are reading from input/input.xlsx
.
My conf.py
looks like:
import os
import sys
sys.path.insert(0, os.path.abspath('../../'))
extensions = ['sphinx.ext.autodoc']
I run the ./docs/sphinx-apidoc -o ./source ../
where it creates a:
module.rst
and:
My_Project.rst
inside the ./docs/source
.
My issue is that when I build the make html
, it gives me errors like:
FileNotFoundError: [Errno 2] No such file or directory: './input'
However, as I have set in conf.py
, it should logically go two levels high and one level down to /input
folder.
../../input
Appreciate any ideas.
Upvotes: 4
Views: 2112
Reputation: 213
Finally I figured out something that worked for me. Beforehand, I need to clarify something: in one of python files located in ../../
from my source
directory, the code is reading an excel file from this path ./input/input.xlsx
. I figured out that defining a hard coded path is the source of this issue. So I fixed it with following code:
directory_path = os.path.dirname(os.path.abspath(__file__))
new_path = os.path.join(directory_path, "input.xlsx")
Upvotes: 2