Getting X server to work with ETE in a Docker container

559 views
Skip to first unread message

dmkos...@gmail.com

unread,
Jan 20, 2016, 12:22:46 PM1/20/16
to The ETE toolkit
Hello,

I am encountering the "ETE: cannot connect to X server" problem when trying to use the t.render("mytree.png", w=183, units="mm") command in a Docker container with ETE3 installed.

I saw the post about using the local host X server with Docker:
https://groups.google.com/forum/#!searchin/etetoolkit/ETE$3A$20cannot$20connect$20to$20X$20server/etetoolkit/4SrZk5fRtCM/CDE2fbrxr3IJ

but I would prefer not to go that route (as I want the Docker to work on Windows machines as well as *nix based ones).

I noticed that the typical advice is "install a lightweight X server, like xdm, and then change a few configuration settings". Being a complete novice to X servers, I don't have the slightest idea what settings need to be modified.

What I have done so far is:
apt-get install -y xdm
xhost + (this results in the error xhost: unable to open display. I still get the ETE error when trying t.render)

Perhaps someone could point me in the right direction, or detail the configurations that you have to modify to get this to work.

Thanks,

~David

Jaime Huerta Cepas

unread,
Jan 20, 2016, 12:35:28 PM1/20/16
to eteto...@googlegroups.com
Hi David, 
you don't need to install xdm or a real X server. 
We found that the tool "xvfb" available in most distros works as a charm in servers without screen running ETE. 

All you need is to install xvfb-run and prepend it to the python command using ete. 
for instance, the following has worked out of the box in all servers I have tried so far (Ubuntu/CentOS):
xvfb-run python -c 'from ete3 import Tree. Tree().render("test.png")'

Some systems may need som extra config for xvfb, but that's the general idea. 
 


--
You received this message because you are subscribed to the Google Groups "The ETE toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to etetoolkit+...@googlegroups.com.
To post to this group, send email to eteto...@googlegroups.com.
Visit this group at https://groups.google.com/group/etetoolkit.
For more options, visit https://groups.google.com/d/optout.

dmkos...@gmail.com

unread,
Jan 20, 2016, 1:03:54 PM1/20/16
to The ETE toolkit
That worked like a charm! Thank you!

jsh...@gmail.com

unread,
Aug 10, 2017, 2:33:19 PM8/10/17
to The ETE toolkit
Hi!! is there anyway to setup xvfb to be used by python directly so ETE can be used witin code instead as a command line?

Best

Sergio

Renato Alves

unread,
Aug 10, 2017, 5:17:32 PM8/10/17
to eteto...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi Sergio,

You can use whatever method to start xvfb, including python's subprocess module.
However, if you start it like that it won't affect the already active python session.

To do that, you need to make sure that whatever DISPLAY port is configured with xvfb is also set in the current python session environment.
Setting something like `os.environ["DISPLAY"] = port` and afterwards importing ete3 should work as expected.

Best,
Renato
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEErWzyn8km9Qx1yUkopwPBKi+mXQQFAlmMzVIACgkQpwPBKi+m
XQQYKQ//cH/xXq305DPVF4Cwf9RdiPEFsA/oYIOPxN4iYyvyKQU6ls4U555KvGCR
wFzQuabb6st1z2CQxiEATLacRaB/eUhxRk/RYe3o8a42HztlL7TGQl/4bDLAeD5s
qnGln5NJIt/CNhFEtOQ1LoHdsd3hoggMYIgqNfxVkVmPIoB8hrrUkRWY2Y71GFjw
BH1uwRbRv/xu9F6TC3gJIHg00YoDjU9pn3IGZf3fz+N7VwdiDE3X/KorpSJqcFEI
1QBi8/y+bjFpQDW8bTSjciZhKwl8BfTqfbwJUBIvilWJnoa514H0W+dtZWiGV/9Z
YH6YNFntyPOjAzx1KFoIbErA1ItaTd5mWbQxESHdNlqp0EkkUHawdlRlYfUA3dlQ
C2pwQuLOCLP2PkUp/LgStEPkQsnGlEPe9RVoIdA0g2O4wioJl335a+5o68BMk0Yu
kuk2D1ZHBxqAkFgRe5sWoeYU/axbJEqHpJiIwwBq2F2kX84K76qGoTnVfO15QtJl
Z0etw+SToa07OKXkDsOVwnOIWb302oyGOOX/j95z6HrhS2KLzbbGVxtZAXbBxupn
Yf33MX3nOZ/afmsSPoTDJr0RtqG1NoNM6h6MCtz3/ODDreqAYNzxHdSiRG8juwex
WzIN7ljZUSSxFYLuSZdo5oakIywg7jtY/qAq1cH6wq6zs80wYPw=
=tatW
-----END PGP SIGNATURE-----

dayimeh...@gmail.com

unread,
Jan 27, 2019, 4:59:04 AM1/27/19
to The ETE toolkit
Hi Renato,

during the test step of ete tool; I received these messages:

~/applications/ete-master/ete3/test/test_tree.py:58: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/etetemptree.nw' mode='w' encoding='UTF-8'>
open("/tmp/etetemptree.nw","w).write(nw_full)
~/applications/ete-master/ete3/parser/newick.py:239: DeprecationWarning: 'U' mode is deprecated
nw = open(newick, 'rU').read()
~/applications/ete-master/ete3/parser/newick.py:239: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/etetemptree.nw' mode='rU' encoding='UTF-8'>
nw = open(newick, 'rU').read()
....Duplicated entry [Mmu_001] was renamed to [1_Mmu_001]
Warnning: [5] terminal nodes could not be found in the alignment.
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-user12'
qt.qpa.screen: QXcbConnection: Could not connect to display
Could not connect to any X display.
ERRORS FOUND!

ERROR: One or more tests failed on test_3.5

How can I solve this?

best
Reply all
Reply to author
Forward
0 new messages