How to make sphinx look for modules in virtualenv while building html?

cerberos picture cerberos · Nov 8, 2010 · Viewed 8.4k times · Source

I want to build html docs using a virtualenv instead of the native environment on my machine.

I've entered the virtualenv but when I run make html I get errors saying the module can't be imported - I know the errors are due to the module being unavailable in my native environment. How can I specify which environment should be used when searching for docs (eg the virtualenv)?

Answer

migonzalvar picture migonzalvar · Jul 8, 2012

The problem is correctly spotted by Mathijs.

$ which sphinx-build
/usr/local/bin/sphinx-build

I solved this issue installing sphinx itself in the virtual environment.

With the environment activated:

$ source /home/migonzalvar/envs/myenvironment/bin/activate
$ pip install sphinx
$ which sphinx-build
/home/migonzalvar/envs/myenvironment/bin/sphinx-build

It seems neat enough.