[英]“module 'locale' has no attribute 'normalize'” when running python-sphinx
I am trying to generate a documentation for my python project using Sphinx. 我正在尝试使用Sphinx为我的python项目生成一个文档。 The commands I'm running are:
我正在运行的命令是:
sphinx-quickstart
sphinx-apidoc -o rst .
make html
However, when executing the last command, I get the following error: 但是,执行最后一个命令时,我收到以下错误:
Traceback (most recent call last):
File "C:\winpython-3.5.2.3-win64\python-3.5.2.amd64\lib\site-p
ackages\sphinx\__main__.py", line 14, in <module>
sys.exit(main(sys.argv))
File "C:\winpython-3.5.2.3-win64\python-3.5.2.amd64\lib\site-p
ackages\sphinx\__init__.py", line 51, in main
sys.exit(build_main(argv))
File "C:\winpython-3.5.2.3-win64\python-3.5.2.amd64\lib\site-p
ackages\sphinx\__init__.py", line 61, in build_main
from sphinx import cmdline
File "C:\winpython-3.5.2.3-win64\python-3.5.2.amd64\lib\site-p
ackages\sphinx\cmdline.py", line 14, in <module>
import optparse
File "C:\winpython-3.5.2.3-win64\python-3.5.2.amd64\lib\optpar
se.py", line 421, in <module>
_builtin_cvt = { "int" : (_parse_int, _("integer")),
File "C:\winpython-3.5.2.3-win64\python-3.5.2.amd64\lib\gettex
t.py", line 514, in gettext
return dgettext(_current_domain, message)
File "C:\winpython-3.5.2.3-win64\python-3.5.2.amd64\lib\gettex
t.py", line 478, in dgettext
codeset=_localecodesets.get(domain))
File "C:\winpython-3.5.2.3-win64\python-3.5.2.amd64\lib\gettex
t.py", line 413, in translation
mofiles = find(domain, localedir, languages, all=True)
File "C:\winpython-3.5.2.3-win64\python-3.5.2.amd64\lib\gettex
t.py", line 385, in find
for nelang in _expand_lang(lang):
File "C:\winpython-3.5.2.3-win64\python-3.5.2.amd64\lib\gettex
t.py", line 114, in _expand_lang
loc = locale.normalize(loc)
AttributeError: module 'locale' has no attribute 'normalize'
I already checked whether there are other locale.py files somewhere, but I couldn't find any. 我已经检查过某处是否有其他locale.py文件,但我找不到任何文件。 Furthermore, in my own scripts I can import
locale
and call normalize
. 此外,在我自己的脚本中,我可以导入
locale
并调用normalize
。
I'm using python 3.5 我正在使用python 3.5
To solve this I created a Python environment and installed sphinx
in that environment. 为了解决这个问题,我创建了一个Python环境并在该环境中安装了
sphinx
。
Then from that environment I ran: 然后从那个环境我运行:
make html
and it worked perfectly. 它工作得很好。
I think is a problem with the Python versions or, maybe, it gets confused with other packages. 我认为是Python版本的问题,或者,它可能与其他软件包混淆。
Updating sphinx on my computer solved the issue. 在我的计算机上更新sphinx解决了这个问题。
In my case I ran conda install sphinx
在我的情况下,我运行了
conda install sphinx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.