Python - Sphinx:模糊导入错误

时间:2016-12-26 17:52:21

标签: python numpy python-sphinx importerror documentation-generation

我正在尝试从我的项目中的注释(以numpydoc样式)生成API文档,我被困在sphinx的模糊导入错误中:

/home/carbolymer/workspace/si-app/doc/source/scripts.rst:10: WARNING: autodoc: failed to import module 'scripts.backtest'; the following exception was raised:
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/sphinx/ext/autodoc.py", line 547, in import_object
    __import__(self.modname)
  File "/home/carbolymer/workspace/si-app/application/scripts/backtest.py", line 6, in <module>
    from scipy import stats
  File "/usr/lib/python3.5/site-packages/scipy/__init__.py", line 64, in <module>
    from numpy import __version__ as __numpy_version__
ImportError: cannot import name '__version__'
/home/carbolymer/workspace/si-app/doc/source/scripts.rst:18: WARNING: autodoc: failed to import module 'scripts.importdb'; the following exception was raised:
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/sphinx/ext/autodoc.py", line 547, in import_object
    __import__(self.modname)
  File "/home/carbolymer/workspace/si-app/application/scripts/importdb.py", line 5, in <module>
    from si.storage.dataimport import DataImport, database_drivers, sources
  File "/home/carbolymer/workspace/si-app/application/si/storage/dataimport.py", line 6, in <module>
    from si.storage.datasource.file import Stooq as StooqFile
  File "/home/carbolymer/workspace/si-app/application/si/storage/datasource/file.py", line 19, in <module>
    from si.storage.datasource.util import correct_prices
  File "/home/carbolymer/workspace/si-app/application/si/storage/datasource/util.py", line 4, in <module>
    def correct_prices(dataframe, calendar=PolishCalendar()):
  File "/usr/lib/python3.5/unittest/mock.py", line 917, in __call__
    return _mock_self._mock_call(*args, **kwargs)
  File "/usr/lib/python3.5/unittest/mock.py", line 976, in _mock_call
    result = next(effect)
StopIteration

完整日志:

http://pastebin.com/tycmVQdN

我尝试过模仿numpy.__version__,但它不起作用。另外我不知道包含PolishCalendar()的行是什么 - 为什么sphinx试图模仿这个对象?

由于这些导入错误,文档中缺少这些文件。我该如何解决这个问题?

我的构建命令:

make clean ; sphinx-apidoc -a -f -o ./source ../application ; make html

版本:

$ sphinx-build --version
Sphinx (sphinx-build) 1.5.1
$ python --version                                                        
Python 3.5.2

source / conf.py: http://pastebin.com/VfsiX4uZ

0 个答案:

没有答案