It seems your case is simply python's problem, not sphinx's.
How about this?
sys.path.insert(0, os.path.abspath(".."))
Thanks,
Takeshi KOMIYA
2017-02-18 9:33 GMT+09:00 nshea <[email protected]>:
> The way my modules are structured, there is an __init__.py in both the
> python_modules_A and the python_modules_B directories. I declared two paths
> in my conf.py, one for python_modules_A and python_modules_B but when I run
> make.html, sphinx only recognizes the first path listed and ignores the
> second.
>
> For example, in my conf.py file, I used
>
> sys.path.insert(0, os.path.abspath("../python_modules_A"))
> sys.path.insert(0, os.path.abspath("../python_modules_B"))
>
> but get import errors for every python module in the python_modules_B
> directory.
>
> Another error that comes up when I list sys.path.insert(0,
> os.path.abspath("../python_modules_B")) first instead is that sphinx cannot
> recognize the path for functions/modules in python_modules_A that are
> imported into python_module_B modules. For example, in every module in
> python_module_B, I import a module/function defined in python_modules A
> called download parameters. Here is how it is listed below:
>
> download_parameters.py is in python_modules_A directory
> Below is the header and code in a2.py (which is in the python_modules_B
> directory):
>
> import numpy as np
> from python_modules_A.download_parameters import download_parameters
> Class module_B
> ...
> ...
>
> This error occurs:
>
> "from python_modules_A.download_parameters import download_parameters
>
> ImportError: No module named python_modules_A.download_parameters"
>
>
> Is there a way to fix this problem as well? Thanks.
>
>
> On Thursday, February 16, 2017 at 5:33:26 AM UTC-8, Peter Burdine wrote:
>>
>> Have you tried changing your sys.path to include both? Eg:
>> sys.path.insert(0, os.path.abspath(".."))
>>
>>
>>
>> Then for autodoc tried:
>> .. automodule:: python_modules_A
>>
>> .. automodule:: python_modules_B
>>
>>
>>
>> How you include documentation for it may then depend on your module
>> structure (eg do you have an __init__.py? does it define __all__?)
>>
>> On Wednesday, February 15, 2017 at 3:05:18 PM UTC-8, nshea wrote:
>>>
>>> I am using sphinx autodoc to document python modules in multiple
>>> directories. I already have the rst files for each python module and can use
>>> autodoc when declaring a path to one directory with the python modules but I
>>> am trying to document python modules from two different directories. In the
>>> conf.py file, I used:
>>>
>>>
>>> sys.path.insert(0, os.path.abspath("../python_modules_A"))
>>>
>>>
>>> but would like to have paths to both python_modules_A and
>>> python_modules_B, since my modules are in both directories. Given the
>>> structure of my project team, I would like to avoid having to restructure
>>> the modules into one directory since they are separated by helper functions
>>> in python_module_A and classes/objects for the main module python_modules_B
>>> modules.
>>>
>>>
>>> Below is how my directories are configured:
>>>
>>>
>>> sphinx_doc_setup
>>>
>>> conf.py
>>>
>>> index.rst
>>>
>>> a1.rst
>>>
>>> b1.rst
>>>
>>> a2.rst
>>>
>>> b2.rst
>>>
>>> python_modules_A
>>>
>>> a1.py
>>>
>>> b1.py
>>>
>>> python_modules_B
>>>
>>> a2.py
>>>
>>> b2.py
>>>
>>>
>>> Thanks for any help!
>
> --
> You received this message because you are subscribed to the Google Groups
> "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sphinx-users.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.