2017-07-03 2 views
2

Je générais des documents en utilisant la bibliothèque sphinx python, et je rencontre l'erreur can not import normalize.Sphinx Erreur: Impossible d'importer normaliser en utilisant la commande "make html"

J'ai trouvé un similar question de 2014 mais cela ne résout pas mon problème.

Code d'essai

# 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) 

Sphinx et installation Locale

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

Sphinx commandes

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. 

T sa procédure fonctionne au this youtube video.

Cependant, si je répète la même procédure, je suis l'erreur suivante:

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 

drôle est quand j'importer Normaliser de locale je reçois pas d'erreur, et ne sphynx donne cette erreur.

Question
Comment pouvons-nous produire de la documentation à l'aide sphynx en évitant l'erreur d'importation?

Aide sera appréciée !!

Liens
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

+0

Avez-vous un fichier ou un dossier appelé "locale" ou "locale.py" quelque part dans votre projet? Voir https://stackoverflow.com/a/10875148/407651 – mzjn

+0

@mzjn Pas vraiment, il n'y a pas de locale.py. Le projet n'a qu'un fichier HELLO.PY –

+0

Je ne sais pas comment le reproduire. Si possible, fournissez un [mcve]. – mzjn

Répondre

1

J'ai eu deux installations différentes de Python, à savoir, python2 et python3. Les deux ont des modules sphinx et en quelque sorte ils se sont mélangés et ont donné le problème. Pour l'instant ce que je faisais était suit:

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 

Téléchargez et installez l'installateur de python3 graphique de anaconda.
Ensuite, cela a fonctionné sans aucun problème.