Question

I'm executing sphinx-build to transform some rst files to html. But I get an error because the script it's trying to import modules from an old Python installation.

My environment:

The command executed is:

sphinx-build -b html -d _build/doctrees   . _build/html

And the error text is as follows

Traceback (most recent call last):
  File "/usr/local/bin/sphinx-build", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 2556, in <module>
    """
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 620, in require
    ``resolve()`` method. The `fallback` flag indicates whether we should
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 518, in resolve
    yield self.by_key[key]
pkg_resources.DistributionNotFound: Jinja2>=2.3
make: *** [html] Error 1

I'm pretty sure I have Jinja 2.6 installed. The problem is it's installed for Python 2.7, and the sphinx-build.py script is, somehow, using the Python 2.6 modules directory (you can see the path to Python 2.6 directory in the error text).

My doubt is: why is the script searching in that directory? Some facts

  • I didn't define PYTHONPATH variable, and if I just load python interpreter and print sys.path, I get all the directories belonging to Python 2.7. Not a single mention to Python 2.6 directories.
  • There isn't a .pth file including directories of Python 2.6 in my working directory

So, what I'm missing? Why is Python 2.7 looking in directories of Python 2.6?

UPDATE: Looks like sphinx-build was built using Python2.6. I deleted it, but now I can't get it back. I've installed Sphinx and docutils, but sphinx-build is not installed :-(. Any clues?

Many thanks in advance

Was it helpful?

Solution

Ok, it was a stupid mistake. The sphinx-build binary was built using Python 2.6. I deleted it, and rebuilt sphinx with Python 2.7.

After that, the binary was put in /Library/Frameworks/Python.framework/Versions/2.7/bin/. I just created a symbolic link to /Library/Frameworks/Python.framework/Versions/2.7/bin/sphinx-build in /usr/local/bin (it wasn't created, for any reason). Now it works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top