telegram-export
telegram-export copied to clipboard
Error when executing telegram-export
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
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)
.
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.
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.
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.
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.