-1

When I try to install opencv-python 4.3.0.38 using pip with pip install opencv-python on python 2.7, I'm getting the following error.

Collecting opencv-python
  Using cached opencv-python-4.3.0.38.tar.gz (88.0 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 1:
   command: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python /Library/Python/2.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /var/folders/ch/hg1k0nj940g6n47qv36jjzs00000gn/T/tmpmJirQh
       cwd: /private/var/folders/ch/hg1k0nj940g6n47qv36jjzs00000gn/T/pip-install-rayarg/opencv-python
  Complete output (22 lines):
  Traceback (most recent call last):
    File "/Library/Python/2.7/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
      main()
    File "/Library/Python/2.7/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/Library/Python/2.7/site-packages/pip/_vendor/pep517/_in_process.py", line 114, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/private/var/folders/ch/hg1k0nj940g6n47qv36jjzs00000gn/T/pip-build-env-_bx9RN/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 146, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
    File "/private/var/folders/ch/hg1k0nj940g6n47qv36jjzs00000gn/T/pip-build-env-_bx9RN/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 127, in _get_build_requires
      self.run_setup()
    File "/private/var/folders/ch/hg1k0nj940g6n47qv36jjzs00000gn/T/pip-build-env-_bx9RN/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 243, in run_setup
      self).run_setup(setup_script=setup_script)
    File "/private/var/folders/ch/hg1k0nj940g6n47qv36jjzs00000gn/T/pip-build-env-_bx9RN/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 142, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 448, in <module>
      main()
    File "setup.py", line 99, in main
      % {"ext": re.escape(sysconfig.get_config_var("EXT_SUFFIX"))}
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 210, in escape
      s = list(pattern)
  TypeError: 'NoneType' object is not iterable
  ----------------------------------------
ERROR: Command errored out with exit status 1: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python /Library/Python/2.7/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /var/folders/ch/hg1k0nj940g6n47qv36jjzs00000gn/T/tmpmJirQh Check the logs for full command output.

How do I fix this? Am I missing something?

1 Answer 1

5

opencv-python on version 4.3.0.38 is not supported on Python 2.7. You can check this issue for more information.

You should use Python 3 instead or, as a workaround on Python 2.7, you can install an oldest version of opencv-python compatible with your python version, like 4.2.0.32. Use:

pip install opencv-python==4.2.0.32 
2
  • Thank you so much! It works now.
    – Cai Tufei
    Commented Nov 15, 2021 at 17:11
  • Good to read! If this or any answer has solved your question, remember that you can accept it by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both. Of course there is no obligation to do this ;).
    – Latra
    Commented Nov 16, 2021 at 8:25

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.