skip to Main Content

First of all, I am a beginner in the Linux environment

I have used the command below in python to open the Telegram Desktop in the Windows 10 environment and it works correctly:

subprocess.Popen('C:\Users\username\AppData\Roaming\Telegram Desktop\Telegram.exe')

But now I want to do the same thing in python but in the Ubuntu environment. I have used the command below to do it but it does not work:

subprocess.Popen('\home\username\snap\telegram-desktop\2551\.local\share\TelegramDesktop')

Error = "No such a file or directory"

Maybe I have a problem with the installation path for the telegram. Consider that I found the path using <locate> command in terminal

2

Answers


  1. Unix uses / as a path separator. You have \ instead which makes this look like one long file name, not a path.

    Login or Signup to reply.
  2. Because of historical reasons, Windows uses the backslash symbol () as the path separator, while Linux/UNIX systems use the forward-slash (/).

    When a path begins with /, it is interpreted as an absolute path, otherwise, it is treated as a relative one (if it contains at least one forward-slash) or as a command which can be found by the PATH environment variable.

    When you write

    subprocess.Popen('\home\username\snap\telegram-desktop\2551\.local\share\TelegramDesktop')
    

    Python tries to find a file in the PATH with has this big 70-characters long name. If you want to specify an absolute file path instead, you should do

    subprocess.Popen('/home/username/snap/telegram-desktop/2551/.local/share/TelegramDesktop')
    

    If this still throws the FileNotFound exception, it’s most likely that you have just specified a wrong file path. If you’re having the Permission Denied error, you might not have the executing permission for this file (learn more by searching for "Linux execute permission")

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search