Ubuntu: unoconv is not working in python


I've an issue while using unoconv to convert docs to html from a Python script.

It works perfectly when I run the script or the unoconv commands as root, but it fails when I do the same from other user. I had installed Ubuntu 13.04 Server and unoconv packages via apt-get install. I executed the python script as an ordinary (not root) user

>>> from subprocess import call  >>> call(["unoconv","-f","html","-o","/var/www/project/tagging/templates/documents","/var/www/project/media/resume1.doc"])  Error: Unable to connect or start own listener. Aborting.  

ls -l give the following:

ubuntu@ip-54-194-10-89:/var/www$ ls -l  total 183184  drwxr-xr-x 24 www-data www-data      4096 Aug 31 15:20 project  

project has group and ownership as www-data

If anyone who can help me with this issue it would be appreciated.


Before going to do that you need to start the unoconv listener then only it will start. open your terminal with CTRL+ALT+Tand start the listener as

unoconv --listener  

Then try again with your operation of conversion.

NOTE: make sure that no other process using the listener, If any process do so , kill that process to assign the listener to current conversion.

hope that helps.


If you're calling from Python, this is an easier solution:

import os  import subprocess    # Copy the environment, and add home to the enviornment  env = os.environ.copy()  env['HOME'] = '/tmp'    p = subprocess.Popen(["unoconv","-f", "html", "-o", "output.html",      "input1.doc"], env = env)  out, err = p.communicate()  

The issue is that unoconv needs a writeable HOME directory in order to start the listener. When you're calling from django, that HOME directory is not set. Setting it manually to /tmp solves this issue.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »