1

So I am trying to open a URL in Epiphany [ let's say for example http://www.google.com ] from a python script. My python script is as follows:

import os
string = "DISPLAY=:0 xdg-open http://www.google.com"
os.system(string)

It returns the error: xdg-open: no method available for opening 'http://www.google.com'

However if I type DISPLAY=:0 xdg-open http://www.google.com into LXTerminal is works fine. It also works remotely through SSH.

Any Ideas? Also can someone explain to me why command were find in terminal, but not when you try to call them from a Python script?

UPDATE -- NEED HELP STILL

NOTE: All files are located in /home/pi

After much frustration, I figured I would give the below method a try. I created a file called google.sh. The code for google.sh s as follows:

#google.sh    
DISPLAY=:0 xdg-open http://www.google.com

when I call upon this program using ./google.sh from LXTerminal it works fine! Great so now let's call it from a python script called test.py whose code is as follows:

# test.py
import os

string = "/home/pi/google.sh"
os.system(string)

However for some reason it STILL returns: xdg-open: no method available for opening 'http://www.google.com'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.