Repository: stepjam/RLBench
Issue: qt.qpa.xcb: could not connect to display
Root cause: Environment Incompatibility

```
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/user1/CoppeliaSim" even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, webgl, xcb. Aborted (core dumped)
```


I install from offical website   `https://downloads.coppeliarobotics.com/V4_1_0/CoppeliaSim_Edu_V4_1_0_Ubuntu20_04.tar.xz `   instead of `wget https://downloads.coppeliarobotics.com/V4_1_0/CoppeliaSim_Edu_V4_1_0_Ubuntu20_04.tar.xz`  But it should be same. 

and install pyrep 

For headless server, it is diffcult.

I did 
```
echo "export COPPELIASIM_ROOT=/openpi/CoppeliaSim_Edu_V4_1_0_Ubuntu20_04" >> ~/.bashrc; 
echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:\$COPPELIASIM_ROOT" >> ~/.bashrc;
echo "export QT_QPA_PLATFORM_PLUGIN_PATH=\$COPPELIASIM_ROOT" >> ~/.bashrc;
```


I also tried 
```
#!/bin/bash

export DISPLAY=:99
export QT_QPA_PLATFORM=xcb  
export QT_X11_NO_MITSHM=1


python try.py
```

 try.py is following:
```python
import numpy as np
from rlbench.action_modes.action_mode import MoveArmThenGripper
from rlbench.action_modes.arm_action_modes import JointVelocity
from rlbench.action_modes.gripper_action_modes import Discrete
from rlbench.environment import Environment
from rlbench.tasks import FS10_V1

action_mode = MoveArmThenGripper(
  arm_action_mode=JointVelocity(),
  gripper_action_mode=Discrete()
)
env = Environment(action_mode, headless=True)
env.launch()

train_tasks = FS10_V1['train']
test_tasks = FS10_V1['test']
task_to_train = np.random.choice(train_tasks, 1)[0]
task = env.get_task(task_to_train)
task.sample_variation()  # random variation
descriptions, obs = task.reset()
obs, reward, terminate = task.step(np.random.normal(size=env.action_shape))
```


this can works 
```
#!/bin/bash
COPPELIA_QT=$(find /home/user1/openpi/CoppeliaSim_Edu_V4_1_0_Ubuntu20_04/ -name "platforms" -type d | head -1)
COPPELIA_PLUGINS=$(dirname "$COPPELIA_QT")


echo "export QT_PLUGIN_PATH=\"$COPPELIA_PLUGINS\""
echo "export QT_QPA_PLATFORM_PLUGIN_PATH=\"$COPPELIA_QT\""

export QT_PLUGIN_PATH=$COPPELIA_PLUGINS
export QT_QPA_PLATFORM_PLUGIN_PATH=$COPPELIA_QT
export PYOPENGL_PLATFORM="osmesa"
export DISPLAY=":99"
export COPPELIASIM_ROOT=/home/user1/workspace/CoppeliaSim_Edu_V4_1_0_Ubuntu20_04
export LD_LIBRARY_PATH=$COPPELIASIM_ROOT:$LD_LIBRARY_PATH

Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
XVFB_PID=$!
sleep 2

trap "kill $XVFB_PID 2>/dev/null" EXIT
python main.py --args.task_name close_jar --args.num_trials 5 --args.headless
```

also getting this error:
```
$ test.py
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in "/home/jstm/miniconda3/envs/aldarobots/lib/python3.10/site-packages/cv2/qt/plugins"
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Aborted (core dumped) 
```

> also getting this error:
> 
> ```
> $ test.py
> qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in "/home/jstm/miniconda3/envs/aldarobots/lib/python3.10/site-packages/cv2/qt/plugins"
> This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
> 
> Aborted (core dumped) 
> ```

That's a conflict with opencv-python. I didn't need opencv, so I uninstalled it, and then things worked out, so if you don't need it maybe `pip uninstall opencv-python`


Following up on @aagha6 's comment, after you uninstalled cv, you can install `pip install opencv-python-headless`