我正在尝试使用 Sphinx 为 python 项目自动生成文档。其中一个模块需要 scipy.signal 包,我尝试使用以下命令导入:import scipy.signal as signal。虽然代码运行得很好,但使用 Sphinx 制作 html 会导致分段错误(下面的输出)。但是,我可以使用“import scipy as sp”,确保将 scipy 目录放在我的 sys.path 中,并且生成的文档没有任何问题,但是当然,我的代码中将没有我的功能需要。
我做了一个非常简单的测试用例来演示这个问题,用几个文档字符串创建了一个测试类。我将它与我的 .rst 一起包含在下面。注释掉“import scipy.signal as signal”这一行,一切正常。
感谢您对如何在导入 scipy.signal 的同时避免段错误的任何见解。劳伦
狮身人面像输出:
sphinx-build -b html -d _build/doctrees . _build/html
Running Sphinx v1.0.5
loading pickled environment... done
building [html]: targets for 1 source files that are out of date
updating environment: 0 added, 1 changed, 0 removed
make: *** [html] Segmentation faults
pyexample.py
import scipy.signal as signal
class TestClass:
"""The TestClass class is used to lalala. I would like this docstring to be documented by sphinx.
"""
def __init__(self, A, B):
self.A = A
self.B = B
# Style to use for printing
def __str__(self):
str = "A = " + self.A.__str__() + "\n\n"
str += "B = " + self.B.__str__() + "\n\n"
return str
def __add__(self):
"""Add A+B."""
total = self.A+self.B
return total
def addx(self,x):
"""Add A+x."""
total = self.A+x
return total
索引.rst
.. Test documentation master file, created by
sphinx-quickstart on Sun Jan 2 20:34:04 2011.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Test's documentation!
================================
Contents:
.. toctree::
docstrings
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
文档字符串.rst
My Modules and Functions
************************************
Here are some modules.
The pyexample Module
======================
.. automodule:: pyexample
.. autoclass:: pyexample.TestClass
:members: