0

I'm building documentation with sphinx. I use a conda setup and have py27 and py36 version of python that I switch between. On running sphinx-build ./source ./build I get the following error:

WARNING: /home/b3053674/Documents/pytseries/docs/source/index.rst:14: (WARNING/2) autodoc: failed to import module u'pytseries.core'; the following exception was raised:
Traceback (most recent call last):
  File "/home/b3053674/anaconda2/lib/python2.7/site-packages/sphinx/ext/autodoc.py", line 657, in import_object
    __import__(self.modname)
  File "/home/b3053674/Documents/pytseries/pytseries/core.py", line 193
    ts = TimeSeries(**args, feature=self.feature)
                          ^

Note that **args is a dictionary and that none of my tests give me a syntax error.

After looking again it looks as though the docs for my Python 3 project is being built with a python2.7 interpreter (even though my py36 env is active). I suspect this may be reeking havoc but I can't get sphinx to use my python 3 interpretor.

So how can I get sphinx to use Python 3 as an interpreter?

Edit

also node I have seen this question and have installed python3-sphinx

CiaranWelsh
  • 7,014
  • 10
  • 53
  • 106
  • 1
    Whenever I have a problem with virtual environments, I delete it and start over. I use only pip to install packages (do not use both setuptools and pip, that only ends badly). I don't activate, but instead use the filepath to Python in my commands, e.g., `env/bin/python` or `make html SPHINXBUILD=../env/bin/sphinx-build`. I don't use conda. Packaging is hard enough without another factor to deal with. – Steve Piercy Jun 11 '18 at 19:10

1 Answers1

0

With a "Anaconda3" installer, this should work by default.

Else, from https://conda.io/docs/user-guide/tasks/manage-pkgs.html#installing-packages

conda install sphinx -n py36_env

where py36_env is the name of a Python 3 environment.

Alternatively,

python3 -m pip install --user sphinx

should work as well.

Then, edit the Makefile to replace the line

SPHINXBUILD   = sphinx-build

by

SPHINXBUILD   = python3 -m sphinx
Pierre de Buyl
  • 7,074
  • 2
  • 16
  • 22