read-the-docs - 属性错误: '_NamespacePath' object has no attribute 'sort' on Read the docs

标签 read-the-docs

很确定这不是骗局。

我的阅读文档构建在这里失败:

Collecting sphinxcontrib-inlinesyntaxhighlight==0.2 (from -r /home/docs/checkouts/readthedocs.org/user_builds/zproc/checkouts/latest/requirements.txt (line 33))
  Using cached https://files.pythonhosted.org/packages/5c/8b/17998fe9ebbec7e176f344648a86094d7b358e63d8f4593ae3dfbb9bb560/sphinxcontrib-inlinesyntaxhighlight-0.2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/docs/checkouts/readthedocs.org/user_builds/zproc/envs/latest/lib/python3.5/site-packages/setuptools/__init__.py", line 10, in <module>
        from setuptools.extern.six.moves import filter, filterfalse, map
      File "/home/docs/checkouts/readthedocs.org/user_builds/zproc/envs/latest/lib/python3.5/site-packages/setuptools/extern/__init__.py", line 1, in <module>
        from pkg_resources.extern import VendorImporter
      File "/home/docs/checkouts/readthedocs.org/user_builds/zproc/envs/latest/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3017, in <module>
        @_call_aside
      File "/home/docs/checkouts/readthedocs.org/user_builds/zproc/envs/latest/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3003, in _call_aside
        f(*args, **kwargs)
      File "/home/docs/checkouts/readthedocs.org/user_builds/zproc/envs/latest/lib/python3.5/site-packages/pkg_resources/__init__.py", line 3045, in _initialize_master_working_set
        dist.activate(replace=False)
      File "/home/docs/checkouts/readthedocs.org/user_builds/zproc/envs/latest/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2577, in activate
        declare_namespace(pkg)
      File "/home/docs/checkouts/readthedocs.org/user_builds/zproc/envs/latest/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2151, in declare_namespace
        _handle_ns(packageName, path_item)
      File "/home/docs/checkouts/readthedocs.org/user_builds/zproc/envs/latest/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2091, in _handle_ns
        _rebuild_mod_path(path, packageName, module)
      File "/home/docs/checkouts/readthedocs.org/user_builds/zproc/envs/latest/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2120, in _rebuild_mod_path
        orig_path.sort(key=position_in_sys_path)
    AttributeError: '_NamespacePath' object has no attribute 'sort'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-wlv3e5i4/sphinxcontrib-inlinesyntaxhighlight/
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

看起来安装sphinxcontrib-inlinesyntaxhighlight失败,它在我的本地计算机上安装得很好。

一个简单的搜索似乎表明可以使用pip install --upgrade pip setuptools修复它,但我不知道如何在阅读文档时做到这一点。

这是我提供的用于阅读文档的requirements.txt

alabaster==0.7.11
Babel==2.6.0
backcall==0.1.0
certifi==2018.4.16
chardet==3.0.4
decorator==4.3.0
docutils==0.14
idna==2.7
imagesize==1.0.0
ipython==6.4.0
ipython-genutils==0.2.0
jedi==0.12.1
Jinja2==2.10
MarkupSafe==1.0
packaging==17.1
parso==0.3.0
pexpect==4.6.0
pickleshare==0.7.4
pkginfo==1.4.2
prompt-toolkit==1.0.15
psutil==5.4.6
ptyprocess==0.6.0
Pygments==2.2.0
pyparsing==2.2.0
pytz==2018.5
pyzmq==17.0.0
requests==2.19.1
requests-toolbelt==0.8.0
simplegeneric==0.8.1
six==1.11.0
snowballstemmer==1.2.1
Sphinx==1.7.5
sphinxcontrib-inlinesyntaxhighlight==0.2
sphinxcontrib-websupport==1.1.0
tblib==1.3.2
tinydb==3.9.0.post1
tqdm==4.23.4
traitlets==4.3.2
twine==1.11.0
urllib3==1.23
wcwidth==0.1.7

最佳答案

按照建议here.并引用相同内容 -

_path_ 属性应始终被视为可交互的,而不是列表(Python 文档将 _path_ 描述为可迭代的)。 pkg_resources/_init_.py 中的行如下:

orig_path.sort(key=position_in_sys_path)  

应该是:

orig_path = sorted(orig_path, key=position_in_sys_path)  

作为一般规则(如果可行),不应使用就地排序。

PS- 我尝试升级 pipsetuptools 但它对我不起作用。

pip install -U pip
pip install -U setuptools

关于read-the-docs - 属性错误: '_NamespacePath' object has no attribute 'sort' on Read the docs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51236366/

相关文章:

python - 如何覆盖 readthedocs 上的模板?

python - 狮身人面像/autodoc : how to cross-link to a function documented on another page

python - 如何撰写 PyPI 项目描述的内容?

python-sphinx - 我如何告诉 readthedocs 要加载哪个需求文件?

docker - 无法在docker中启动Read the Docs

python - 当页面上不存在该短语时,"Searching..."需要永远读取文档

python-2.7 - 狮身人面像 : Linking to Embedded Binary Files (PDFs)

python - 我可以在阅读文档中构建和托管自定义 HTML 页面吗?

python - 为什么 RTD 在构建时运行 "python env create"而不是 "conda env create"?

python-sphinx - 在 Sphinx 中使用 iframe 嵌入外部 html 文件