AnsweredAssumed Answered

Using sphinx-apidoc to autodocument EMPro python scripts

Question asked by RyanA Employee on Aug 18, 2016
Latest reply on Sep 2, 2016 by WDING

A colleague and I have a large corpus of EMPro python scripts. We want to document this code using sphinx-apidoc to pull in existing docstrings from modules and classes. The problem happens when running "make html," where we receive the following import error:


C:\data\empro\library\docs>make clean


C:\data\empro\library\docs>sphinx-apidoc -f -o \source ..\
Creating file \source\patterns.rst.
Creating file \source\substrates.rst.
Creating file \source\tools.rst.
Creating file \source\modules.rst.


C:\data\empro\library\docs>make html

Running Sphinx v1.4.5

making output directory...

loading pickled environment... not yet created

building [mo]: targets for 0 po files that are out of date

building [html]: targets for 5 source files that are out of date

updating environment: 5 added, 0 changed, 0 removed

reading sources... [100%] tools

C:\data\empro\library\docs\source\patterns.rst:10: WARNING: autodoc: failed to import module u'patterns.arbWidthModulatedFilter'; the following exception was raised:

Traceback (most recent call last):

File "c:\python27\lib\site-packages\sphinx\ext\", line 518, in import_object __import__(self.modname)

File "C:/data/empro/library/patterns\", line 2, in <module>

    import empro

File "C:/apps/emp2015_01/win32_64/bin/empro\", line 2, in <module>

    import libpyshared

ImportError: DLL load failed: %1 is not a valid Win32 application.


The error we receive appears to be related to this question about running python scripts from inside an IDE. The recommend solution was to start the IDE from the EMPro environment. However, when we try running sphinx-apidoc from the EMPro environment, it produces another import error (this time it can't import sphinx.apidoc, even though it was able to before).


Setting environment for using EMPro's python distribution
setting EMPROHOME to C:\Keysight\EMPro2015_01\win32_64\bin\
setting PYTHONHOME to C:\Keysight\EMPro2015_01\win32_64\bin\tools\win32\python
setting HPEESOF_DIR to C:\Keysight\EMPro2015_01\win32_64\bin\


C:\Keysight\EMPro2015_01\win32_64\bin>cd C:\data\empro\library\docs


C:\data\empro\library\docs>make clean


C:\data\empro\library\docs>sphinx-apidoc -f -o \source ..\
Traceback (most recent call last):
  File "C:\Keysight\EMPro2015_01\win32_64\bin\tools\win32\python\lib\",
line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Keysight\EMPro2015_01\win32_64\bin\tools\win32\python\lib\",
line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\sphinx-apidoc.exe\", line 5, in <module>
ImportError: No module named sphinx.apidoc



It is curious to me that as soon as I enter the EMPro environment, it suddenly has trouble locating the sphinx.apidoc module (which is definitely a part of my PYTHONPATH). Is there a workaround for this? Any help would be appreciated.