2017-11-11 156 views
0

我triyng用獅身人面像來記錄我的django項目,但我遇到了一些麻煩。獅身人面像在Anaconda下運行,但我的Django項目在Python 3.5.2下

當我運行make html命令我得到這個錯誤:

/home/santoryu/richiestaTesi/docs/models/models.rst:3: WARNING: autodoc: 
failed to import module u'myapp.models'; the following exception was 
raised: 
Traceback (most recent call last): 
    File "/home/santoryu/anaconda2/lib/python2.7/site-packages/Sphinx- 
1.5.6-py2.7.egg/sphinx/ext/autodoc.py", line 560, in import_object 
__import__(self.modname) 
    File "/home/santoryu/richiestaTesi/myapp/models.py", line 8 
SyntaxError: Non-ASCII character '\xc3' in file 
/home/santoryu/richiestaTesi/myapp/models.py on line 8, but no encoding 
declared; see http://python.org/dev/peps/pep-0263/ for details 

很明顯的錯誤發生,因爲蟒蛇非ASCII字符本身不支持,但在Python 3.5.2他們。所以我猜如何強制Python 3.5.2執行Sphinx?

+0

項目被記錄python 3特定? –

回答

2

錯誤消息表明您已將Sphinx安裝到Python 2.7虛擬環境中。

File "/home/santoryu/anaconda2/lib/python2.7/site-packages/Sphinx- 
1.5.6-py2.7.egg/sphinx/ext/autodoc.py", line 560, in import_object 
__import__(self.modname) 

您也可以爲Python 2.7而不是3.6安裝Anaconda。

確保您下載並安裝了適用於Python 3.6的Anaconda並且您的use Anaconda to create a virtual environment using Python 3.6用於安裝Sphinx。