question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] opencv-python vs opencv-python-headless dependency issue

See original GitHub issue

Important Note: We do not do technical support, nor consulting and don’t answer personal questions per email. Please post your question on reddit or stack overflow in that case.

If your issue is related to a custom gym environment, please use the custom gym env template.

🐛 Bug

Currently you have your setup.py file configured to install opencv-python. However, in your docker file you then uninstall opencv-python and install opencv-python-headless. I assume this is because you get a segmentation fault in the docker container unless you do this step.

I have a repo with stable-baselines3 as a dependency. I had my tests working locally (macOS), but got a segmentation fault in CI (ubuntu).

I use Poetry, so I have resolved the issue using environment markers in my dependency configuration.

` stable-baselines3 = “0.10.0”

atari_py = {version = “~0.2”}

opencv-python-headless = {version = “~4.5”, markers = “sys_platform == ‘linux’”}

opencv-python = {version = “~4.5”, markers = “sys_platform == ‘darwin’”} `

If you used poetry you could take a similar approach, which would be cleaner than your current solution, I think.

To Reproduce

Install stable-baselines3[extra] in ubuntu and then run the following:

from stable_baselines3 import ...


Current thread 0x00007f0eee355740 (most recent call first):
  File "/usr/local/lib/python3.7/ctypes/__init__.py", line 364 in __init__
  File "/usr/local/lib/python3.7/site-packages/torch/__init__.py", line 142 in _load_global_deps
  File "/usr/local/lib/python3.7/site-packages/torch/__init__.py", line 189 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 728 in exec_module
  File "<frozen importlib._bootstrap>", line 677 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 967 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 983 in _find_and_load
  File "/usr/local/lib/python3.7/site-packages/stable_baselines3/a2c/a2c.py", line 3 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 728 in exec_module
  File "<frozen importlib._bootstrap>", line 677 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 967 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 983 in _find_and_load
  File "/usr/local/lib/python3.7/site-packages/stable_baselines3/a2c/__init__.py", line 1 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 728 in exec_module
  File "<frozen importlib._bootstrap>", line 677 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 967 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 983 in _find_and_load
  File "/usr/local/lib/python3.7/site-packages/stable_baselines3/__init__.py", line 3 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 728 in exec_module
  File "<frozen importlib._bootstrap>", line 677 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 967 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 983 in _find_and_load
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 953 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 983 in _find_and_load
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 953 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 983 in _find_and_load
  File "/build/offpolicydqn/envs/crmsubscriber/env.py", line 19 in <module>
  File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 728 in exec_module
  File "<frozen importlib._bootstrap>", line 677 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 967 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 983 in _find_and_load
  File "/Users/thomas.furmston/farfetch/code/marketplace-marketing-offpolicydqn/tests/offpolicydqn/envs/crmsubscriber/test_env.py", line 7 in <module>
  File "/usr/local/lib/python3.7/site-packages/_pytest/assertion/rewrite.py", line 152 in exec_module
  File "<frozen importlib._bootstrap>", line 677 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 967 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 983 in _find_and_load
  File "/usr/local/lib/python3.7/site-packages/py/_path/local.py", line 704 in pyimport
  File "/usr/local/lib/python3.7/site-packages/_pytest/python.py", line 511 in _importtestmodule
  File "/usr/local/lib/python3.7/site-packages/_pytest/python.py", line 443 in _getobj
  File "/usr/local/lib/python3.7/site-packages/_pytest/python.py", line 261 in obj
  File "/usr/local/lib/python3.7/site-packages/_pytest/python.py", line 459 in _inject_setup_module_fixture
  File "/usr/local/lib/python3.7/site-packages/_pytest/python.py", line 446 in collect
  File "/usr/local/lib/python3.7/site-packages/_pytest/runner.py", line 264 in <lambda>
  File "/usr/local/lib/python3.7/site-packages/_pytest/runner.py", line 244 in from_call
  File "/usr/local/lib/python3.7/site-packages/_pytest/runner.py", line 264 in pytest_make_collect_report
  File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/usr/local/lib/python3.7/site-packages/pluggy/manager.py", line 87 in <lambda>
  File "/usr/local/lib/python3.7/site-packages/pluggy/manager.py", line 93 in _hookexec
  File "/usr/local/lib/python3.7/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/usr/local/lib/python3.7/site-packages/_pytest/runner.py", line 382 in collect_one_node
  File "/usr/local/lib/python3.7/site-packages/_pytest/main.py", line 681 in genitems
  File "/usr/local/lib/python3.7/site-packages/_pytest/main.py", line 684 in genitems
  File "/usr/local/lib/python3.7/site-packages/_pytest/main.py", line 490 in _perform_collect
  File "/usr/local/lib/python3.7/site-packages/_pytest/main.py", line 452 in perform_collect
  File "/usr/local/lib/python3.7/site-packages/_pytest/main.py", line 257 in pytest_collection
  File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/usr/local/lib/python3.7/site-packages/pluggy/manager.py", line 87 in <lambda>
  File "/usr/local/lib/python3.7/site-packages/pluggy/manager.py", line 93 in _hookexec
  File "/usr/local/lib/python3.7/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/usr/local/lib/python3.7/site-packages/_pytest/main.py", line 246 in _main
  File "/usr/local/lib/python3.7/site-packages/_pytest/main.py", line 191 in wrap_session
  File "/usr/local/lib/python3.7/site-packages/_pytest/main.py", line 240 in pytest_cmdline_main
  File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/usr/local/lib/python3.7/site-packages/pluggy/manager.py", line 87 in <lambda>
  File "/usr/local/lib/python3.7/site-packages/pluggy/manager.py", line 93 in _hookexec
  File "/usr/local/lib/python3.7/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/usr/local/lib/python3.7/site-packages/_pytest/config/__init__.py", line 125 in main
  File "/usr/local/bin/pytest", line 8 in <module>
Segmentation fault

Expected behavior

No segmentation fault.

### System Info

Describe the characteristic of your environment:

  • Describe how the library was installed (pip, docker, source, …) - pip
  • GPU models and configuration - cpu
  • Python version - 3.7
  • PyTorch version - 1.7
  • Gym version - 1.7
  • Versions of any other relevant libraries

Additional context

Add any other context about the problem here.

Checklist

  • [ x ] I have checked that there is no similar issue in the repo (required)
  • [ x ] I have read the documentation (required)
  • [ x ] I have provided a minimal working example to reproduce the bug (required)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tfurmstoncommented, Jan 21, 2021

OK, cool.

Yes, it is a bit niche, I suppose. 😃

I’ll submit a PR for the documentation.

0reactions
araffincommented, Jan 21, 2021

I was suggesting this could be improved, or atleast more clearly documented.

As it is quite a specific problem. I would rather document it, we already have that [extra] option and I don’t think we need to add an option that may not be used that often. I would be happy if you could submit a PR to update the documentation =) (I’m not sure what is the best section: probably “installation” or “developer guide”)

Read more comments on GitHub >

github_iconTop Results From Across the Web

opencv-python-headless - PyPI
Old Anaconda versions have a bug which causes the error, see this issue for a manual fix. If you still encounter the error...
Read more >
opencv-python-headless [python-library] - Occam :: Details
Old Anaconda versions have a bug which causes the error, see this issue for a manual fix. If you still encounter the error...
Read more >
2054951 – RPM Python package doesn't provide python3dist ...
I compared file names in opencv-python and opencv-contrib-python. They are almost identical if not for a folder name.
Read more >
Can not get opencv imported in either python or node.js - Bugs
This means that the packages avoid a heavy dependency chain to X11 libraries and you will have for example smaller Docker images as...
Read more >
Install albumentations with custom opencv-python version ...
When I pip install , it seems to choose opencv-python-headless , which has a bug that prevents installation. (If you read the bug,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found