狮身人面像错误:使用命令"make html"时无法导入规范化



>我正在使用狮身人面像python库生成文档,我遇到了can not import normalize错误。

我在 2014 年发现了一个类似的问题,但它并不能解决我的问题。

测试代码

# hello.py
def myadd(a,b):
"""

Parameters
----------
a: first parameter
b: second paramter

Returns
-------
Return: Sum of two arguments
"""
return a+b
if __name__=="__main__":
a = myadd(5,6) 
print('n')
print(a)

狮身人面像和语言环境安装

import sphinx
from locale import normalize # I got no error here
print(sphinx.__version__) # 1.6.2

狮身人面像命令

sphinx-quickstart
> Project name: a
> Author name(s): a
> Create Makefile? (y/n) [y]: 
> Create Windows command file? (y/n) [y]: n
this creates THREE files and THREE folders.
Then,
make html # this gives the error.

此过程在此YouTube视频中有效。

但是,如果我重复相同的过程,则会出现以下错误:

File "/usr/lib/python2.7/gettext.py", line 440, in find
for nelang in _expand_lang(lang):
File "/usr/lib/python2.7/gettext.py", line 133, in _expand_lang
from locale import normalize
ImportError: cannot import name normalize
Makefile:20: recipe for target 'html' failed
make: *** [html] Error 1

有趣的是,当我从语言环境导入规范化时,我没有收到任何错误,并且 只有狮身人面像给出这个错误。

问题
我们如何通过避免导入错误来使用 sphinx 生成文档?

帮助将不胜感激!!

相关链接
http://www.sphinx-doc.org/en/stable/tutorial.html http://www.sphinx-doc.org/en/stable/ext/example_google.html


https://thomas-cokelaer.info/tutorials/sphinx/docstring_python.html http://gisellezeno.com/tutorials/sphinx-for-python-documentation.html

我有两个不同的Python安装,即python2和python3。 两者都有模块狮身人面像,不知何故它们混合并给出了问题。现在我所做的是:

ls /Library/Frameworks/Python.framework/Versions/3.6
sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.6
ls "/Applications/Python/3.6
sudo rm -rf "/Applications/Python/3.6

从 anaconda 下载并安装图形 python3 安装程序。
然后它没有任何问题。

最新更新