Dav*_*ave 6 django documentation importerror python-sphinx
我正在尝试将我的sphinx文档与阅读文档相关联.我可以在本地构建文档,但是当我尝试阅读文档时自动生成文档时,我收到以下错误:
狮身人面像标准错误
Making output directory...
Exception occurred:
File "/var/build/user_builds/mousedb/checkouts/latest/Docs/source/conf.py", line 25, in <module>
from mousedb import settings
ImportError: No module named mousedb
The full traceback has been saved in /tmp/sphinx-err-n_8fkR.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
Either send bugs to the mailing list at <http://groups.google.com/group/sphinx-dev/>,
or report them in the tracker at <http://bitbucket.org/birkenfeld/sphinx/issues/>. Thanks!
Run Code Online (Sandbox Code Playgroud)
我的项目名称是mousedb.我不明白为什么我在自动构建中获得此导入错误但不在本地.
更新
根据评论我认为这是将我的设置文件导入兄弟Docs目录的问题.我应该根据settings.py和conf.py的位置进行相对导入,而不是进行绝对导入(就像我一直在做的那样)
我想将我的设置文件导入我的conf.py,其目录结构如下:
-mousedb
--settings.py
-Docs
--source
---conf.py
--build
Run Code Online (Sandbox Code Playgroud)
您最初谈到了"我的代码的本地绝对路径",现在谈到了设置代码的相对路径.这可能意味着你没有使用setup.py文件,也没有使用virtualenv.
在与Docs/and 相同的目录中mousedb/,添加一个setup.py:
from setuptools import setup
setup(name='mousedb',
version='0.1',
description="My sample package",
long_description="",
author='TODO',
author_email='todo@example.org',
license='TODO',
packages=['mousedb'],
zip_safe=False,
install_requires=[
'Django',
# 'Sphinx',
# ^^^ Not sure if this is needed on readthedocs.org
# 'something else?',
],
)
Run Code Online (Sandbox Code Playgroud)
提交/推送/无论此文件后,您都可以转到项目的readthedocs设置.启用"使用virtualenv"设置.这将"使用setup.py install"在virtualenv中安装你的项目".
最终的结果是,与readthedocs相关的所有与python相关的东西都将包含你的项目sys.path.
您的问题的可能原因是您在本地系统的"root"目录中运行sphinx,其中python神奇地mousedb/在当前目录中找到该包.但readthedocs显然是从Docs/目录中运行它,因此无法找到mousedb.
| 归档时间: |
|
| 查看次数: |
1515 次 |
| 最近记录: |