我正在尝试使用Sphinx自动生成python项目的文档。其中一个模块需要scipy.signal包,我尝试使用以下方法导入:import scipy.signal as signal。虽然代码运行得很好,但使用Sphinx制作html会导致分段错误(下面的输出)。但是,我可以使用“import scipy as sp”,确保将scipy目录放在我的sys.path中,文档生成没有任何问题,但当然,我的代码中没有我的功能需要。
我做了一个非常简单的测试用例来演示这个问题,用一些docstrings创建一个测试类。我和我的.rst一起在下面提到它。在评论“将scipy.signal导入为信号”这一行时,一切都运行良好。
感谢您在导入scipy.signal时如何避免seg faulting的任何见解。 劳伦
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
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
.. 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`
My Modules and Functions
************************************
Here are some modules.
The pyexample Module
======================
.. automodule:: pyexample
.. autoclass:: pyexample.TestClass
:members: