How set $Display variables on Apache2 running on Ubuntu 16

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








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?










share|improve this question





















  • 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














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?










share|improve this question





















  • 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












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?










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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
















  • 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










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






share|improve this answer




















  • 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










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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






























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






share|improve this answer




















  • 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














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






share|improve this answer




















  • 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












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






share|improve this answer












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







share|improve this answer












share|improve this answer



share|improve this answer










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
















  • 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

















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































Popular posts from this blog

pylint3 and pip3 broken

Missing snmpget and snmpwalk

How to enroll fingerprints to Ubuntu 17.10 with VFS491