readthedocs.org: Error: cannot connect to X server

First, thank you for enabling conda builds on RTD!

I am now trying to build the docs for http://www.glueviz.org using this, and am running into the following error:

Running Sphinx v1.3.1
making output directory...

Installed /home/docs/checkouts/readthedocs.org/user_builds/glueviz/checkouts/latest/doc/.eggs/astropy_helpers-1.1.1-py2.7.egg
/home/docs/checkouts/readthedocs.org/user_builds/glueviz/conda/latest/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
  warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
: cannot connect to X server 

My readthedocs.yml file contains:

conda:
    file: .environment.yml

python:
    setup_py_install: true

and the .environment.yml contains:


name: glueviz

dependencies:
  - pyqt
  - numpy
  - matplotlib
  - pandas
  - astropy
  - dill
  - h5py
  - scipy
  - scikit-image
  - ipython
  - ipykernel
  - qtconsole
  - traitlets
  - pygments
  - pyzmq
  - mock
  - pytest

I think the cannot connect to X server error occurs when PyQt4 is imported.

On Travis, I normally fix this by doing:

export DISPLAY=:99.0
sh -e /etc/init.d/xvfb start

Is there any way of doing something similar on RTD?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

FYI for others trying to figure out how to setup headless displays on Read The Docs:

I ran into this issue using sphinx-gallery with vtki to build these examples in our documentation.

Since RTD cannot handle headless displays, I outright switched my projects to deploying from Travis to GitHub pages using doctr: https://github.com/drdoctr/doctr

It works wonderfully and now we have a custom job that builds and deploys the docs on Travis which turns up as a status check on PRs - hope this helps others out there struggling to get RTD to meet their projects’ needs!

Also, I created a ci helper script that can handle setting up all of this on Travis - simply add this to your .travis.yml:

dist: xenial # must use xenial for vtk/vtki

before_install:
  # configure a headless display for vtk/vtki
  - git clone --depth 1 git://github.com/vtkiorg/gl-ci-helpers.git
  - source ./gl-ci-helpers/travis/setup_headless_display.sh

then build your docs and use doctr to deploy!

Perfect. It does not bypass the setup.cfg. For others, I just created a docs/requirements.txt with a single line

sphinx==1.7.5

and declared docs/requirements.txt in the readthedocs project admin>advanced settings>Requirements file Thank you, readthedocs is great !

@ederag you can specify any version of sphinx in your requirements.txt file

Is there any progress on this? I’m trying to build the documentation with some mayavi examples and I need the X server. In travis I just set up a headless server as pointed out in the first post. Is it possible to use it here too?