I am trying to run a spider on a vps (using scrapyjs which uses python-gtk2). On running the spider I am getting the error
/root/myporj/venv/local/lib/python
Probably you run the application over ssh? Then, you need to run X server on local PC. If not, you should set DISPLAY environment variable correctly. Recently, sudo command on Ubuntu doesn't some transfer environment variable. If you run the application over sudo, make sure $DISPLAY is set or not.
Additional
It's a bug of pygtk. You app should be depend on gtk widget.
https://bugs.launchpad.net/ubuntu/+source/software-center/+bug/800574
First of all, you didn't specify if you have a desktop environment (or X) installed on your server?
Regardless of that, you can achieve headless setup for your spider by using xvfb
:
Xvfb or X virtual framebuffer is a display server implementing the X11 display server protocol. In contrast to other display servers Xvfb performs all graphical operations in memory without showing any screen output. From the point of view of the client, it acts exactly like any other X display server, serving requests and sending events and errors as appropriate. However, no output is shown. This virtual server does not require the computer it is running on to even have a screen or any input device.
First, install xvfb
on your server. Assuming you are using apt-get
:
sudo apt-get install xvfb
Now, run the xvfb service at a custom display number, like:
sudo Xvfb :5
After that, you can run any application that requires X
inside your virtual frame buffer by exporting the display number and running your application:
export DISPLAY=:5
run_my_application
The DISPLAY
is set only for the current terminal session, so keep that in mind when implementing automation for this step.