Forums

can't sudo, can't fix XDG_RUNTIME_DIR error?

In one of my scripts, I'm using a library called abiword (not a Python library, it's for Ubuntu). As far as I know, it's the only non-GUI platform available to convert .doc files to HTML.

Anyway, whenever I run it, I get errors. When printed:

[b'error: XDG_RUNTIME_DIR not set in the environment.\n', b'\n', b' (abiword:23444): WARNING : clutter failed 0, get a life.\n', b'error: XDG_RUNTIME_DIR not set in the environment.\n']

I've inspected several SO threads, with some solutions suggesting using sudo visudo, or something called pkexec. None of which seem to be available on my console. I've searched and found that PyAny doesn't support sudo.

Any suggestion for fixing the above without utilizing sudo?

Did you try setting XDG_RUNTIME_DIR to a directory that you can write to?

I have to admit I'm not really good with paths, so no. How would I go about doing this? I tried googling XDG_RUNTIME_DIR but all results point to question threads like mine but none really explain what it is.

The way I understand it, sudo doesn't carry used-specific variables, and one would use sudo visudo to change that:

https://askubuntu.com/questions/456689/error-xdg-runtime-dir-not-set-in-the-environment-when-attempting-to-run-naut

Try export XDG_RUNTIME_DIR = /tmp in a bash console before you try to use abiword, or put it in your .bashrc

Estou com um problema semelhante ao tentar usar o abiword. Tentei: abiword --to=pdf recibo2.doc Obtive erro: ============================================================ 10:43 ~/web2py/applications/ifce/uploads $ abiword --to=pdf recibo2.doc error: XDG_RUNTIME_DIR not set in the environment.

** (abiword:5835): WARNING **: clutter failed 0, get a life. error: XDG_RUNTIME_DIR not set in the environment. AbiWord: [recibo2.doc] is not a valid file name. ============================================================= Tentei: export XDG_RUNTIME_DIR = /tmp E Obtive o erro: ============================================================= 10:49 ~/web2py/applications/ifce/uploads $ export XDG_RUNTIME_DIR = /tmp bash: export: =': not a valid identifier bash: export:/tmp': not a valid identifier =============================================================

Como devo proceder?

export XDG_RUNTIME_DIR = /tmp Não funciona!

Estou tentando usar o abiword para converter docx em pdf e estou obtendo o erro:

11:02 ~/web2py/applications/ifce/uploads $ dir
Artigov4.docx  auth_user.foto           evento.logomarca_evento  trabalho.poster_digital  versoes_trabalho.arquivo
RECIBO2.doc    evento.arquivo_template  evento.regras_submissao  trabalho.primeiro_envio
11:02 ~/web2py/applications/ifce/uploads $ abiword --to=pdf artigov4.docx
error: XDG_RUNTIME_DIR not set in the environment.

** (abiword:10396): WARNING **: clutter failed 0, get a life.
error: XDG_RUNTIME_DIR not set in the environment.
AbiWord: [artigov4.docx] is not a valid file name.

[edit by admin: formatting]

Comandos e nomes de arquivos no Linux fazem distinção entre maiúsculas e minúsculas, portanto, deve usar isto:

abiword --to=pdf Artigov4.docx

...observe a maiúscula "A".

Obrigado. o abiword funcionou com a observação da letra maiúscula, mas a qualidade do pdf não é satisfatória alguns elementos do docx não foram inseridos, o arquivo tinha 15 páginas e o abiword só converteu 3 páginas. Existe no pythonanywhere alguma outra ferramenta para conversão de docx para pdf já instalada? libreoffice? uncova?

Infelizmente não temos nenhum outra programa para converter PDFs :-(

Existe no pythonanywhere alguma forma de imprimir em PDF?

You can try using weasyprint, which we should already have installed.