telegram-export icon indicating copy to clipboard operation
telegram-export copied to clipboard

Error when executing telegram-export

Open ApexLead opened this issue 6 years ago • 5 comments

Ive installed and changed everything by the instructions, but after I change the config's values and execute telegram-export, the terminal just waits untill I press something and then throws this error:

/usr/local/bin/telegram-export: line 2: syntax error near unexpected token "telegram_export",' /usr/local/bin/telegram-export: line 2: runpy.run_module("telegram_export", run_name="main", alter_sys=True)'

How can I fix that? Thanks in advance

ApexLead avatar Jul 18 '18 12:07 ApexLead

Looks to me like the script is being executed with a shell, rather than with python. The syntax error is caused by the Python code being invalid shell syntax. This is a problem with the setup.py script and the way it installs from PyPI, but I couldn't recreate it. A workaround would be to run python3 /usr/local/bin/telegram-export or python3 $(which telegram-export).

expectocode avatar Jul 21 '18 07:07 expectocode

It could also be solved by adding a shebang (#!/usr/bin/env python3) to the top of the script, but python's setuptools tries to be clever and replaces that with its evaluation on my system (this caused a bug in the past, so we removed the shebang). You could add this yourself, though.

expectocode avatar Jul 21 '18 07:07 expectocode

I also experienced this error on Ubuntu 18.04 LTS.

Installed using sudo pip3 install --upgrade telegram_export. running telegram-export does not work.

Running ~/.local/bin/telegram-export does work. results in the same error as OP.

Running python3 ~/.local/bin/telegram-export does work.

PupoSDC avatar Aug 06 '18 08:08 PupoSDC

I can't see a great way to solve this, as https://github.com/pypa/setuptools/issues/494 is still open. I could add in a common shebang (/usr/bin/python3) which would fix it for most people, though.

expectocode avatar Aug 07 '18 11:08 expectocode

I see this is still open. I was able to fix this by adding this to the top of the file located at /usr/local/bin/telegram-export

#!/usr/bin/env python3

/usr/bin/env is pretty universal (I'll stop short of saying that it is universal) and should use the system available python3 binary without hardcoding the location of said binary.

shinji257 avatar Sep 18 '19 23:09 shinji257