How set $Display variables on Apache2 running on Ubuntu 16
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
0
down vote
favorite
I am running Ubuntu 16 server on Azure. I installed Apache2, then I tried to run a Python code that takes a screenshot and save it on the current directory. The code supposed to take a screenshot from my web page. But when I run it, I get this error in the log:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/mss/linux.py", line 132, in __init__
display = os.environ['DISPLAY'].encode('utf-8')
File "/usr/lib/python3.5/os.py", line 725, in __getitem__
raise KeyError(key) from None
KeyError: 'DISPLAY'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/mss/factory.py", line 34, in mss
return MSS(**kwargs)
File "/usr/local/lib/python3.5/dist-packages/mss/linux.py", line 134, in __init__
raise ScreenShotError('$DISPLAY not set.', locals())
mss.exception.ScreenShotError: ('$DISPLAY not set.', 'display': None, 'self': <mss.linux.MSS object at 0x7f06ce881d30>)
I searched a lot and finally I came to know that this error is related to $Display variables in Ubuntu. So how to fix this and allow my code take a screenshot for my web page and save it to my current directory?
16.04 server apache2 display
 |Â
show 1 more comment
up vote
0
down vote
favorite
I am running Ubuntu 16 server on Azure. I installed Apache2, then I tried to run a Python code that takes a screenshot and save it on the current directory. The code supposed to take a screenshot from my web page. But when I run it, I get this error in the log:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/mss/linux.py", line 132, in __init__
display = os.environ['DISPLAY'].encode('utf-8')
File "/usr/lib/python3.5/os.py", line 725, in __getitem__
raise KeyError(key) from None
KeyError: 'DISPLAY'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/mss/factory.py", line 34, in mss
return MSS(**kwargs)
File "/usr/local/lib/python3.5/dist-packages/mss/linux.py", line 134, in __init__
raise ScreenShotError('$DISPLAY not set.', locals())
mss.exception.ScreenShotError: ('$DISPLAY not set.', 'display': None, 'self': <mss.linux.MSS object at 0x7f06ce881d30>)
I searched a lot and finally I came to know that this error is related to $Display variables in Ubuntu. So how to fix this and allow my code take a screenshot for my web page and save it to my current directory?
16.04 server apache2 display
Without graphical enviroment installed, it is not possible to take screenshot of webpage. Do you run that script in console?
â Pasi Suominen
Mar 20 at 16:53
Using Apache2 I run a web page on the internet. On that web page I have a button that takes a screenshot for the page itself. I hope I explained it in a good way!
â codeDojo
Mar 20 at 16:58
@PasiSuominen if I cannot, then what is the solution? How can I do something like this?
â codeDojo
Mar 20 at 17:00
You have a button on the website? In which viewport you take the screenshot then?
â Pasi Suominen
Mar 21 at 18:20
That is correct. The port number is 80. I deployed a web page using Apache2. In my web page there is a button, when you click on the button it should take a screenshot for the whole page and save it to the current directory. It is working perfectly of the local. But I am getting a $Display error when deploying it
â codeDojo
Mar 22 at 20:03
 |Â
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am running Ubuntu 16 server on Azure. I installed Apache2, then I tried to run a Python code that takes a screenshot and save it on the current directory. The code supposed to take a screenshot from my web page. But when I run it, I get this error in the log:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/mss/linux.py", line 132, in __init__
display = os.environ['DISPLAY'].encode('utf-8')
File "/usr/lib/python3.5/os.py", line 725, in __getitem__
raise KeyError(key) from None
KeyError: 'DISPLAY'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/mss/factory.py", line 34, in mss
return MSS(**kwargs)
File "/usr/local/lib/python3.5/dist-packages/mss/linux.py", line 134, in __init__
raise ScreenShotError('$DISPLAY not set.', locals())
mss.exception.ScreenShotError: ('$DISPLAY not set.', 'display': None, 'self': <mss.linux.MSS object at 0x7f06ce881d30>)
I searched a lot and finally I came to know that this error is related to $Display variables in Ubuntu. So how to fix this and allow my code take a screenshot for my web page and save it to my current directory?
16.04 server apache2 display
I am running Ubuntu 16 server on Azure. I installed Apache2, then I tried to run a Python code that takes a screenshot and save it on the current directory. The code supposed to take a screenshot from my web page. But when I run it, I get this error in the log:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/mss/linux.py", line 132, in __init__
display = os.environ['DISPLAY'].encode('utf-8')
File "/usr/lib/python3.5/os.py", line 725, in __getitem__
raise KeyError(key) from None
KeyError: 'DISPLAY'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/mss/factory.py", line 34, in mss
return MSS(**kwargs)
File "/usr/local/lib/python3.5/dist-packages/mss/linux.py", line 134, in __init__
raise ScreenShotError('$DISPLAY not set.', locals())
mss.exception.ScreenShotError: ('$DISPLAY not set.', 'display': None, 'self': <mss.linux.MSS object at 0x7f06ce881d30>)
I searched a lot and finally I came to know that this error is related to $Display variables in Ubuntu. So how to fix this and allow my code take a screenshot for my web page and save it to my current directory?
16.04 server apache2 display
16.04 server apache2 display
asked Mar 20 at 16:39
codeDojo
183
183
Without graphical enviroment installed, it is not possible to take screenshot of webpage. Do you run that script in console?
â Pasi Suominen
Mar 20 at 16:53
Using Apache2 I run a web page on the internet. On that web page I have a button that takes a screenshot for the page itself. I hope I explained it in a good way!
â codeDojo
Mar 20 at 16:58
@PasiSuominen if I cannot, then what is the solution? How can I do something like this?
â codeDojo
Mar 20 at 17:00
You have a button on the website? In which viewport you take the screenshot then?
â Pasi Suominen
Mar 21 at 18:20
That is correct. The port number is 80. I deployed a web page using Apache2. In my web page there is a button, when you click on the button it should take a screenshot for the whole page and save it to the current directory. It is working perfectly of the local. But I am getting a $Display error when deploying it
â codeDojo
Mar 22 at 20:03
 |Â
show 1 more comment
Without graphical enviroment installed, it is not possible to take screenshot of webpage. Do you run that script in console?
â Pasi Suominen
Mar 20 at 16:53
Using Apache2 I run a web page on the internet. On that web page I have a button that takes a screenshot for the page itself. I hope I explained it in a good way!
â codeDojo
Mar 20 at 16:58
@PasiSuominen if I cannot, then what is the solution? How can I do something like this?
â codeDojo
Mar 20 at 17:00
You have a button on the website? In which viewport you take the screenshot then?
â Pasi Suominen
Mar 21 at 18:20
That is correct. The port number is 80. I deployed a web page using Apache2. In my web page there is a button, when you click on the button it should take a screenshot for the whole page and save it to the current directory. It is working perfectly of the local. But I am getting a $Display error when deploying it
â codeDojo
Mar 22 at 20:03
Without graphical enviroment installed, it is not possible to take screenshot of webpage. Do you run that script in console?
â Pasi Suominen
Mar 20 at 16:53
Without graphical enviroment installed, it is not possible to take screenshot of webpage. Do you run that script in console?
â Pasi Suominen
Mar 20 at 16:53
Using Apache2 I run a web page on the internet. On that web page I have a button that takes a screenshot for the page itself. I hope I explained it in a good way!
â codeDojo
Mar 20 at 16:58
Using Apache2 I run a web page on the internet. On that web page I have a button that takes a screenshot for the page itself. I hope I explained it in a good way!
â codeDojo
Mar 20 at 16:58
@PasiSuominen if I cannot, then what is the solution? How can I do something like this?
â codeDojo
Mar 20 at 17:00
@PasiSuominen if I cannot, then what is the solution? How can I do something like this?
â codeDojo
Mar 20 at 17:00
You have a button on the website? In which viewport you take the screenshot then?
â Pasi Suominen
Mar 21 at 18:20
You have a button on the website? In which viewport you take the screenshot then?
â Pasi Suominen
Mar 21 at 18:20
That is correct. The port number is 80. I deployed a web page using Apache2. In my web page there is a button, when you click on the button it should take a screenshot for the whole page and save it to the current directory. It is working perfectly of the local. But I am getting a $Display error when deploying it
â codeDojo
Mar 22 at 20:03
That is correct. The port number is 80. I deployed a web page using Apache2. In my web page there is a button, when you click on the button it should take a screenshot for the whole page and save it to the current directory. It is working perfectly of the local. But I am getting a $Display error when deploying it
â codeDojo
Mar 22 at 20:03
 |Â
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
To take a screenshot, you first need a viewport that you can duplicate to picture. If you like to render your webpage directly to a picture, I suggest pageres
-> https://github.com/sindresorhus/pageres. Github page covers the installation. Also firefox could be used with some limitations. There is a good article of command line website screenshotting at booleanworld: How to Take Screenshots of Webpages from the Command Line
Thank you so much. It worked and I was able to take a screenshot. But it did not actually solve my problem since I want a screenshot for the whole page but this captured only the html tags without the webcam.
â codeDojo
Mar 25 at 0:02
So do you want to take picture with webcam? Can you explain your problem better? This seems to be an XY problem...
â Pasi Suominen
Mar 25 at 8:17
If you have webcam picture on users browser (sourced from users webcam), you cannot screenshot the page from server side. In that case you need to screenshot on browser side. That is rather complicated but possible with javascript.
â Pasi Suominen
Mar 25 at 19:44
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
To take a screenshot, you first need a viewport that you can duplicate to picture. If you like to render your webpage directly to a picture, I suggest pageres
-> https://github.com/sindresorhus/pageres. Github page covers the installation. Also firefox could be used with some limitations. There is a good article of command line website screenshotting at booleanworld: How to Take Screenshots of Webpages from the Command Line
Thank you so much. It worked and I was able to take a screenshot. But it did not actually solve my problem since I want a screenshot for the whole page but this captured only the html tags without the webcam.
â codeDojo
Mar 25 at 0:02
So do you want to take picture with webcam? Can you explain your problem better? This seems to be an XY problem...
â Pasi Suominen
Mar 25 at 8:17
If you have webcam picture on users browser (sourced from users webcam), you cannot screenshot the page from server side. In that case you need to screenshot on browser side. That is rather complicated but possible with javascript.
â Pasi Suominen
Mar 25 at 19:44
add a comment |Â
up vote
0
down vote
accepted
To take a screenshot, you first need a viewport that you can duplicate to picture. If you like to render your webpage directly to a picture, I suggest pageres
-> https://github.com/sindresorhus/pageres. Github page covers the installation. Also firefox could be used with some limitations. There is a good article of command line website screenshotting at booleanworld: How to Take Screenshots of Webpages from the Command Line
Thank you so much. It worked and I was able to take a screenshot. But it did not actually solve my problem since I want a screenshot for the whole page but this captured only the html tags without the webcam.
â codeDojo
Mar 25 at 0:02
So do you want to take picture with webcam? Can you explain your problem better? This seems to be an XY problem...
â Pasi Suominen
Mar 25 at 8:17
If you have webcam picture on users browser (sourced from users webcam), you cannot screenshot the page from server side. In that case you need to screenshot on browser side. That is rather complicated but possible with javascript.
â Pasi Suominen
Mar 25 at 19:44
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
To take a screenshot, you first need a viewport that you can duplicate to picture. If you like to render your webpage directly to a picture, I suggest pageres
-> https://github.com/sindresorhus/pageres. Github page covers the installation. Also firefox could be used with some limitations. There is a good article of command line website screenshotting at booleanworld: How to Take Screenshots of Webpages from the Command Line
To take a screenshot, you first need a viewport that you can duplicate to picture. If you like to render your webpage directly to a picture, I suggest pageres
-> https://github.com/sindresorhus/pageres. Github page covers the installation. Also firefox could be used with some limitations. There is a good article of command line website screenshotting at booleanworld: How to Take Screenshots of Webpages from the Command Line
answered Mar 21 at 18:48
Pasi Suominen
44526
44526
Thank you so much. It worked and I was able to take a screenshot. But it did not actually solve my problem since I want a screenshot for the whole page but this captured only the html tags without the webcam.
â codeDojo
Mar 25 at 0:02
So do you want to take picture with webcam? Can you explain your problem better? This seems to be an XY problem...
â Pasi Suominen
Mar 25 at 8:17
If you have webcam picture on users browser (sourced from users webcam), you cannot screenshot the page from server side. In that case you need to screenshot on browser side. That is rather complicated but possible with javascript.
â Pasi Suominen
Mar 25 at 19:44
add a comment |Â
Thank you so much. It worked and I was able to take a screenshot. But it did not actually solve my problem since I want a screenshot for the whole page but this captured only the html tags without the webcam.
â codeDojo
Mar 25 at 0:02
So do you want to take picture with webcam? Can you explain your problem better? This seems to be an XY problem...
â Pasi Suominen
Mar 25 at 8:17
If you have webcam picture on users browser (sourced from users webcam), you cannot screenshot the page from server side. In that case you need to screenshot on browser side. That is rather complicated but possible with javascript.
â Pasi Suominen
Mar 25 at 19:44
Thank you so much. It worked and I was able to take a screenshot. But it did not actually solve my problem since I want a screenshot for the whole page but this captured only the html tags without the webcam.
â codeDojo
Mar 25 at 0:02
Thank you so much. It worked and I was able to take a screenshot. But it did not actually solve my problem since I want a screenshot for the whole page but this captured only the html tags without the webcam.
â codeDojo
Mar 25 at 0:02
So do you want to take picture with webcam? Can you explain your problem better? This seems to be an XY problem...
â Pasi Suominen
Mar 25 at 8:17
So do you want to take picture with webcam? Can you explain your problem better? This seems to be an XY problem...
â Pasi Suominen
Mar 25 at 8:17
If you have webcam picture on users browser (sourced from users webcam), you cannot screenshot the page from server side. In that case you need to screenshot on browser side. That is rather complicated but possible with javascript.
â Pasi Suominen
Mar 25 at 19:44
If you have webcam picture on users browser (sourced from users webcam), you cannot screenshot the page from server side. In that case you need to screenshot on browser side. That is rather complicated but possible with javascript.
â Pasi Suominen
Mar 25 at 19:44
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1017686%2fhow-set-display-variables-on-apache2-running-on-ubuntu-16%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Without graphical enviroment installed, it is not possible to take screenshot of webpage. Do you run that script in console?
â Pasi Suominen
Mar 20 at 16:53
Using Apache2 I run a web page on the internet. On that web page I have a button that takes a screenshot for the page itself. I hope I explained it in a good way!
â codeDojo
Mar 20 at 16:58
@PasiSuominen if I cannot, then what is the solution? How can I do something like this?
â codeDojo
Mar 20 at 17:00
You have a button on the website? In which viewport you take the screenshot then?
â Pasi Suominen
Mar 21 at 18:20
That is correct. The port number is 80. I deployed a web page using Apache2. In my web page there is a button, when you click on the button it should take a screenshot for the whole page and save it to the current directory. It is working perfectly of the local. But I am getting a $Display error when deploying it
â codeDojo
Mar 22 at 20:03