0

What I need

I have a Python Selenium script. When I run it on my local Ubuntu PC - it works fine But when I uploaded it to a server I face a problem. The server has no display I solved this problem with X Virtual Framebuffer display. What I need - is to automatically setup the display and run my script in the background

Problem

Now I run it manually the following way

  1. I go to the terminal

  2. Set the display with the following commands

    export DISPLAY=:1

    Xvfb $DISPLAY -screen $DISPLAY 1280x1024x16 &

  3. Run the python script with command python3 products2.py

This works fine.

But I need it to run automatically in the background I created a conf file for supervisor and run the python script with supervisor.

[program:prod]
command = /root/lowescom/l-env/bin/python3.10 /root/lowescom/lowes_project/modules/products2.py
user = root
autorestart = true
redirect_stderr = true
stdout_logfile = /root/lowescom/lowes_project/logs/debug.log

But this don't work. Even if I set up the display manually - it doesn't work

Question

How can I run my python Selenium script in the background automatically. The display setup should also be automated.

Update

I have just tried to use no-sandbox. But still not working

chrome_options = uc.ChromeOptions()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')

driver = uc.Chrome(use_subprocess=True, options=chrome_options)  
2
  • have tried using subprocess? Commented Jan 11, 2023 at 13:03
  • have you tried chrome_options.add_argument('--headless') ? Commented Jan 11, 2023 at 13:41

1 Answer 1

1

if you are using chromedriver you should set the option:

chrome_options.add_argument('--no-sandbox')

for firefox you can check the pyvirtualdisplay module.

Sign up to request clarification or add additional context in comments.

1 Comment

I use undetected_chromedriver. I've updated my question. I added no sandbox. Please look But it still now working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.