我正在使用sphinx python庫生成文檔,並且遇到了 can not import normalize
錯誤。獅身人面像錯誤:使用命令「make html」時無法導入標準化
我發現2014年的similar question,但它不能解決我的問題。
測試代碼
# 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)
斯芬克斯和Locale安裝
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.
Ť他的程序在this youtube video中工作。
但是,如果我重複相同的過程,我得到了以下錯誤:
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
您的項目中是否有文件或文件夾稱爲「locale」或「locale.py」?請參閱https://stackoverflow.com/a/10875148/407651 – mzjn
@mzjn並非如此,沒有任何locale.py。該項目只有一個文件HELLO.PY –
我不知道如何重現這一點。如果可能,請提供[mcve]。 – mzjn