Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ def patch_robocasa_for_windows(rc):
if changed:
demo.write_text(text)

def fix_opencv():
"""Ensure opencv-python (with GUI support) is installed instead of opencv-python-headless.

Transitive dependencies such as open3d and lerobot pull in
opencv-python-headless, which silently replaces opencv-python and
breaks cv2.imshow and other GUI functions.
"""
print("[INFO] Ensuring opencv-python (non-headless) is installed...")
conda_run("pip uninstall -y opencv-python-headless", )
conda_run("pip install opencv-python")

def install_robocasa():
rc = ROOT / "robocasa"
rs = ROOT / "robosuite"
Expand Down Expand Up @@ -176,4 +187,6 @@ def install_robocasa():
if args.robocasa:
install_robocasa()

fix_opencv()

print("[SUCCESS] All requested submodules installed!")
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ license = { text = "MIT" }

dependencies = [
"open3d",
"opencv-python",
"matplotlib",
"scipy",
"tqdm", # useful for progress bars in install.py
Expand Down
27 changes: 13 additions & 14 deletions scripts/teleop_robocasa.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,22 +853,21 @@ def main():

args = parser.parse_args()

# ── Check cv2.imshow availability ──
# opencv-python-headless can overtake opencv-python
# if running locally, remove GUI support.
# ── Check OpenCV variant ──
# local vs using headless / remote environments.
if args.health_hud:
try:
test_img = np.zeros((1, 1, 3), dtype=np.uint8)
cv2.imshow("_probe", test_img)
cv2.destroyWindow("_probe")
cv2.waitKey(1)
except cv2.error:
print("Error: cv2.imshow is not available — your OpenCV build has no GUI support.")
print(" This usually happens when opencv-python-headless shadows opencv-python.")
print(" Fix with:")
print(" pip uninstall -y opencv-python-headless opencv-python")
print(" pip install opencv-python")
sys.exit(1)
import importlib.metadata as importlib_metadata
try:
importlib_metadata.version("opencv-python")
print("Note: opencv-python (GUI) is installed. If you are on a headless server,")
print(" consider switching to the headless variant:")
print(" pip uninstall -y opencv-python opencv-python-headless")
print(" pip install opencv-python-headless")
except importlib_metadata.PackageNotFoundError:
pass
except ImportError:
pass
Comment on lines 858 to +870

# ── macOS GUI requirements ──
# --health-hud / --video: cv2.imshow needs the main thread (no mjpython).
Expand Down
Loading