Forums

xvfb not being found

I've read the previous topics on this issue but the suggestions don't seem to help my case. I'm trying to run a headless Firefox webdriver and am getting a traceback ending with:

"EasyProcessCheckInstalledError: cmd=['Xvfb', '-help'] OSError=[Errno 11] Resource temporarily unavailable Program install error! You can install it in terminal: sudo apt-get install xvfb"

I've cleared out my /tmp folder, and I don't see where else I could be consuming my data quota. I'm at https://warrenwinter.pythonanywhere.com/ . Sorry if this isn't enough info required to help, I'm entirely new to this.

Thanks,

Warren

Weird. I've double-checked your account and you definitely have plenty of disk space free -- just short of 450Mb. Could you paste the code that you're running here? Alternatively, if you'd rather not make it public, you can send it by the "Send feedback" button at the top of the page.

I am facing the same issue, when i run the same code in console it works fine but the same code gives this error when i run it through the request via url

ah- do you mean when your webapp is trying to run the same code? what is the exact error?

Some time it says: BlockingIOError at /w/ [Errno 11] Resource temporarily unavailable

and some time : EasyProcessCheckInstalledError at /w/ cmd=['Xvfb', '-help'] OSError=[Errno 11] Resource temporarily unavailable Program install error! You can install it in terminal: sudo apt-get install xvfb

yes exactly i mean the same code

The resource that is temporarily unavailable is your ability to create new processes because you have left processes lying around from previous hits. You need to be careful about stopping and clearing down selenium and xvfb. There are is an example here. Pay particular attention to the tidy up code.

when the resource will be available?

I have tried your example too, but still its not running and showing the same error

how to close those processes that were left running so that now i start properly with closing commands? Please

For a website, you normally just need to reload it. However, I've cleared everything down on the server manually. If you reload the website now just to be sure, and if you have the cleardown code in the post that Glenn linked to, then that should fix the problem.

It now says : The browser appears to have exited before. . . .

and now again

BlockingIOError at /test/ [Errno 11] Resource temporarily unavailable

please help :)

WebDriverException at /test/ Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.

one thing to remind that the same code is working fine but i try to run that code through web request i=e via a url, then the code gives these kind of errors :) I hope you ll look at this problem and solve it as immediately as possible. Thankyou

that's because the server running your webapp is diff from the server you are running console code on. so if you hadn't cleared down everything in your webapp code/server, then you won't be able to connect.

also what's the full error traceback?

that sounds like you were trying to write to /test/? you can't write there (you can however write to /home/your-user-name/test/`

It was WebDriverException at /test/ Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details. Exception Type: WebDriverException Exception Value:
Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details. Exception Location: /usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/firefox_binary.py in _wait_until_connectable, line 99 Python Executable: /usr/local/bin/uwsgi Python Version: 3.5.2 usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py in inner This decorator is automatically applied to all middleware to ensure that no middleware leaks an exception and that the next middleware in the stack can rely on getting a response instead of an exception. """ @wraps(get_response, assigned=available_attrs(get_response)) def inner(request): try: response = get_response(request) ... except Exception as exc: response = response_for_exception(request, exc) return response return inner

--------------------------------some thing like that --------------------------------------

By the way as you told that its running on different server, so how to clear down everything so it ll work, the thing is that you can your self try whenever i want to use selenium on the webapp server i am unable to do so whereas a month ago i have tested the same and it was working and now when i am going to implement my project it is giving me errors. I am currently testing a code at myusername.com/test

It was WebDriverException at /test/ Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details. Exception Type: WebDriverException Exception Value:
Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details. Exception Location: /usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/firefox_binary.py in _wait_until_connectable, line 99 Python Executable: /usr/local/bin/uwsgi Python Version: 3.5.2 usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py in inner This decorator is automatically applied to all middleware to ensure that no middleware leaks an exception and that the next middleware in the stack can rely on getting a response instead of an exception. """ @wraps(get_response, assigned=available_attrs(get_response)) def inner(request): try: response = get_response(request) ... except Exception as exc: response = response_for_exception(request, exc) return response return inner

--------------------------------some thing like that --------------------------------------

By the way as you told that its running on different server, so how to clear down everything so it ll work, the thing is that you can your self try whenever i want to use selenium on the webapp server i am unable to do so whereas a month ago i have tested the same and it was working and now when i am going to implement my project it is giving me errors. I am currently testing a code at myusername.com/test

the code is in a clear format even the code mentioned by "glenn" isn't working. Whatever i do selenium is not working and giving exceptions.

I've just checked and there are a bunch more Xfvb processes piling up again. I've killed them, but it sounds like some of the clearup code isn't executing. The servers that run console processes are more forgiving of situations where you have a lot of extra processes running (a typical failure mode for web apps is that they start creating lots of processes, so we have to be more careful with them) so that might explain why you're seeing different behaviour.

Can I take a look at your code? We can see it from our admin interface, but we always ask for permission first.

sure, i was running example that time to just check again that is it working now and that code is in /home/mrTalha/SiP/SiP/testfile.py Thankyou for you assistance :)

this time i didn't run anything as this time you check it by yourself so there should no more xvfb processes start

or i ll say make any smaller code example work that uses selenium library, via web servers Thankyou

Hmm, in your example code, you've put the stuff to create the driver and fetch a page (lines 15 and 16) outside the try...except block. I think that might be why it's not clearing up properly, if your website does the same thing. Try moving the "try" up to immediately after the display.start(), like in the sample code.

Dear i have tried that too, even now you can check the code, I came to know that it generates exception when its initialized

I have tried many ways, that is why i am saying that please make any easiest and simplest example to run with selenium via webapp, because it is giving me no way to run it. Thankyou for you assistance :)

Can we take a look at the actual code of your webapp?

yes dear you can look at the actual code too :)

Hmm, there's a lot of code there! I did notice that in a directory called latestCodeScraping, you have some code that doesn't do any of the clearup stuff, and would definitely lead to you having lots of un-stopped Xvfb processes being left around and cause your site to start failing exactly as it does. Are you sure that code isn't being called somehow by your website?

Yes i am hundred percent sure, you can see the url.py file in the SiP directory, for now there are very few scripts are in use :) Thankyou

Where is the code that's doing the Selenium stuff?

Its in the testfile.py in /home/mrTalha/SiP/SiP, which is not running.

There's no way that that code can work - you're not creating a display for Firefox to run on. Also, you're hiding all exceptions so there's no way to tell what is actually going on when you get an exception.

Because i have tried all possible ways, I had created a display too, but still it was unable to run, you can edit to add display too but it will not work, i have given it a lot of time but with or without display, it fails every time :)

Yes. Once again, you're not cleaning up your web driver instances and you're not cleaning up your display instances, so they're piling up and preventing you from starting new ones. Have a look at this help page for code that actually works. Get that runnig as-is, then change it to visit the site that you're interested in.

and this code says UnboundLocalError at /test/ local variable 'browser' referenced before assignment

oo, good point, that is a possible bug! I think the "browser = webdriver.Firefox()" should be outside the try/finally. will update the example!

I've updated the example code now...