Unable to install cv2 dependency for urllib

I’m wanting to use an I.P. camera but can’t seem to get the library to work. I initially tried the urllib camera install (from the “More” menu) on a copy of my test setup with several hardwired and MQTT enabled sensors, etc., already working (32 bit desktop v.11 bullseye, and found, though the camera setup area appeared and allowed me to setup a camera, it didn’t work and ALSO I was no longer able to get any readings on the “live Measurements” page (all showed 0).

Logs showed this several times:
“ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python interpreter from there.”
(I have other old log info available, but I’m hopeful solving the new issue below will also resolve the this one.)

Rather than bother troubleshooting that right now, I pulled the SD card for now and started from scratch.

To try to get something which can be duplicated, I did a new barebones install, using Debian Bookworm OS 32 bit desktop, Mycodo Version: 8.15.12, and only setup an input for the RPi CPU/GPU so I could see some live measurements. Now the cv2 dependency won’t install while trying to install urllib camera library (doesn’t complete installation), so the camera setup properties don’t appear as it did in my earlier attempt. ALSO, the “Live Measurements” page does still show valid measurements instead of “0”s.

BTW, I’m an old guy who’s not too familiar with posting on forums, so please forgive (or teach) me if I don’t give the needed information, or in the wrong format.

Thanks, Bill J

Mycodo Version: 8.15.12
Python Version: 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]
Database Version: 16b28ef31b5b
Debian Bookworm OS 32 bit desktop

The Dependency log follows:
[2023-12-09 13:43:53] Dependency installation beginning. Installing: cv2

[2023-12-09 13:43:53]
[2023-12-09 13:43:53] #### Installing/updating opencv-python==4.6.0.66 (pip-pypi)
[2023-12-09 13:43:57] Looking in indexes: Simple index, piwheels - Simple index
[2023-12-09 13:43:58] Collecting opencv-python==4.6.0.66
[2023-12-09 13:43:58] Using cached opencv-python-4.6.0.66.tar.gz (90.3 MB)
[2023-12-09 13:44:28] Installing build dependencies: started
[2023-12-09 13:44:47] Installing build dependencies: finished with status ‘error’
[2023-12-09 13:44:47] error: subprocess-exited-with-error
[2023-12-09 13:44:47]
[2023-12-09 13:44:47] × pip subprocess to install build dependencies did not run successfully.
[2023-12-09 13:44:47] │ exit code: 1
[2023-12-09 13:44:47] ╰─> [20 lines of output]
[2023-12-09 13:44:47] Looking in indexes: Simple index, piwheels - Simple index, piwheels - Simple index
[2023-12-09 13:44:47] Ignoring numpy: markers ‘python_version == “3.6” and platform_machine != “aarch64” and platform_machine != “arm64”’ don’t match your environment
[2023-12-09 13:44:47] Ignoring numpy: markers ‘python_version == “3.7” and platform_machine != “aarch64” and platform_machine != “arm64”’ don’t match your environment
[2023-12-09 13:44:47] Ignoring numpy: markers ‘python_version == “3.8” and platform_machine != “aarch64” and platform_machine != “arm64”’ don’t match your environment
[2023-12-09 13:44:47] Ignoring numpy: markers ‘python_version <= “3.9” and sys_platform == “linux” and platform_machine == “aarch64”’ don’t match your environment
[2023-12-09 13:44:47] Ignoring numpy: markers ‘python_version <= “3.9” and sys_platform == “darwin” and platform_machine == “arm64”’ don’t match your environment
[2023-12-09 13:44:47] Ignoring numpy: markers ‘python_version == “3.9” and platform_machine != “aarch64” and platform_machine != “arm64”’ don’t match your environment
[2023-12-09 13:44:47] Collecting setuptools==59.2.0
[2023-12-09 13:44:47] Using cached https://www.piwheels.org/simple/setuptools/setuptools-59.2.0-py3-none-any.whl (952 kB)
[2023-12-09 13:44:47] Collecting wheel==0.37.0
[2023-12-09 13:44:47] Using cached https://www.piwheels.org/simple/wheel/wheel-0.37.0-py2.py3-none-any.whl (35 kB)
[2023-12-09 13:44:47] Collecting cmake>=3.1
[2023-12-09 13:44:47] Using cached https://www.piwheels.org/simple/cmake/cmake-3.27.9-cp311-cp311-linux_armv7l.whl (19.3 MB)
[2023-12-09 13:44:47] Collecting pip
[2023-12-09 13:44:47] Using cached https://www.piwheels.org/simple/pip/pip-23.3.1-py3-none-any.whl (2.1 MB)
[2023-12-09 13:44:47] Collecting scikit-build>=0.13.2
[2023-12-09 13:44:47] Using cached https://www.piwheels.org/simple/scikit-build/scikit_build-0.17.6-py3-none-any.whl (84 kB)
[2023-12-09 13:44:47] ERROR: Ignored the following versions that require a different python version: 1.21.2 Requires-Python >=3.7,<3.11; 1.21.3 Requires-Python >=3.7,<3.11; 1.21.4 Requires-Python >=3.7,<3.11; 1.21.5 Requires-Python >=3.7,<3.11; 1.21.6 Requires-Python >=3.7,<3.11
[2023-12-09 13:44:47] ERROR: Could not find a version that satisfies the requirement numpy==1.21.2 (from versions: 1.3.0, 1.4.1, 1.5.0, 1.5.1, 1.6.0, 1.6.1, 1.6.2, 1.7.0, 1.7.1, 1.7.2, 1.8.0, 1.8.1, 1.8.2, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.10.0.post2, 1.10.1, 1.10.2, 1.10.4, 1.11.0, 1.11.1, 1.11.2, 1.11.3, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 1.13.3, 1.14.0, 1.14.1, 1.14.2, 1.14.3, 1.14.4, 1.14.5, 1.14.6, 1.15.0, 1.15.1, 1.15.2, 1.15.3, 1.15.4, 1.16.0, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5, 1.16.6, 1.17.0, 1.17.1, 1.17.2, 1.17.3, 1.17.4, 1.17.5, 1.18.0, 1.18.1, 1.18.2, 1.18.3, 1.18.4, 1.18.5, 1.19.0, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.19.5, 1.20.0, 1.20.1, 1.20.2, 1.20.3, 1.21.0, 1.21.1, 1.22.0, 1.22.1, 1.22.2, 1.22.3, 1.22.4, 1.23.0rc1, 1.23.0rc2, 1.23.0rc3, 1.23.0, 1.23.1, 1.23.2, 1.23.3, 1.23.4, 1.23.5, 1.24.0rc1, 1.24.0rc2, 1.24.0, 1.24.1, 1.24.2, 1.24.3, 1.24.4, 1.25.0rc1, 1.25.0, 1.25.1, 1.25.2, 1.26.0b1, 1.26.0rc1, 1.26.0, 1.26.1, 1.26.2)
[2023-12-09 13:44:47] ERROR: No matching distribution found for numpy==1.21.2
[2023-12-09 13:44:47] [end of output]
[2023-12-09 13:44:47]
[2023-12-09 13:44:47] note: This error originates from a subprocess, and is likely not a problem with pip.
[2023-12-09 13:44:47] error: subprocess-exited-with-error
[2023-12-09 13:44:47]
[2023-12-09 13:44:47] × pip subprocess to install build dependencies did not run successfully.
[2023-12-09 13:44:47] │ exit code: 1
[2023-12-09 13:44:47] ╰─> See above for output.
[2023-12-09 13:44:47]
[2023-12-09 13:44:47] note: This error originates from a subprocess, and is likely not a problem with pip.

[2023-12-09 13:44:48] End install of cv2

[2023-12-09 13:44:49]
[2023-12-09 13:44:49] #### Setting permissions

[2023-12-09 13:44:51] #### Dependencies installed. Restarting frontend and backend…

[2023-12-09 13:44:58] #### Dependency install complete.

What hardware are you running this on?
You really shouldn’t be running the desktop version of the OS, better to use the Lite version, and 64-bit if your hardware can run it. Running the desktop wastes system resources that Mycodo needs.

I’m running Bullseye Lite OS and I have a urllib camera working just fine.

Thank for replying Jason,

In this case I’m using a 3B+ I just took out of service. I just started trying to run a second Pi (the 3B+) for Mycodo experimentation, leaving the one I plan to deploy (Pi4) snugly mounted in its project box. I figured the 3B+ would be adequate as Kyle uses a Pi Zero in his video. I went with 32 bit legacy in October as I figured there were a lot of Pis running Mycodo already and I was running into issues with Mycodo 8.15.10 working well with Bookworm (bad timing).

I’ve decided (learned) I should have the same Pi for experimenting with as the one I’ll be deploying 750 miles away. One will be arriving tomorrow. I’ll also start from scratch yet again, using the 64 bit Bullseye Lite OS you suggest. As I’ve seen Kyle state he’s not going to be able to test/troubleshoot on older versions, I guess I better not continue down the path I was on.

I’m assuming you’re using 64 bit… I saw on stackoverflow a question regarding problems installing the opencv-python on a Pi4 with python 3.11 installed that opencv will only compile on 64-bit arm64 (which I didn’t verify). That may explain it.

I’m currently running 64-bit Bullseye Lite on a Pi 3B+ but I’ve also run on a Pi 4B.
The Mycodo web-gui will feel sluggish on the 3B+, it’s a little faster on the Pi 4B.

As far as I know, urllib is not dependent on opencv.
However, sometimes opencv might be dependent on urllib if that’s the method being used for acquiring an image.
If you are just trying to use urllib to pull images from an IP camera, I don’t think you need opencv.

After a fair amount of consternation which I won’t get into, I finally got 64-bit Bullseye Lite on an SD card and a Pi4B connected to my network, loaded Mycodo and installed the dependencies for the urllib camera library. The install went without a hitch; 64-bit OS was the only difference.

BTW, opencv installs when installing the cv2 dependency (last 2 lines of log below).
…[2023-12-11 15:31:18] Successfully installed numpy-1.26.2 opencv-python-4.6.0.66
[2023-12-11 15:31:19] End install of cv2

The urllib camera library (and the url(requests)) appear to be working now though I still haven’t determined if I can make it work with the spare camera I have (Amcrest PoE IP). I can see a screenshot on my browser using the format of http://:@/cgi-bin/snapshot.cgi but only get “* Error: Could not acquire image.” from Mycodo. Documentation is rather lacking for this so any suggestions would be appreciated.

The other unrelated issue I’m having is trying to import the settings from the Pi3B+ instance I exported yesterday. I’m just getting “Error: Import Settings: Exception while verifying file name: list index out of range”. Perhaps it’s a Mac issue as I had to re-zip the folder Mycodo put in my downloads file. (Mycodo_8-2.zip). Not a critical issue yet, as I didn’t have a whole lot set up yet but I do need to figure out how to make that work.

You’ll need to lookup the specs for that camera and find out the default HTTP address for the still image and video stream.
It’ll be something like:

http://xxx.xxx.xxx.xxx:80/still.jpg
http://xxx.xxx.xxx.xxx:81/stream.mjpeg

Or in your case the http://:@/cgi-bin/snapshot.cgi address you mentioned.

Plug the addresses for your camera into the proper fields in the camera setup…


Also, it’s easier if there is no password on your IP camera as it doesn’t always seem to work trying to pass authentication from the Mycodo camera setup to the camera.

I really don’t recommend trying to do video streaming with Mycodo.
If you do try it, set the stream FPS in the camera settings to 1, but expect it to have issues even at that low frame-rate.
Works just fine for pulling stills though.

I would recommend using the latest version of the Raspberry Pi OS, which is Bookworm. Bullseye is currently an old version.

Sorry, I meant Bookworm, which is what I installed. Bottom line was it took the 64 bit OS to be able to install the cv2 dependency for urllib.

I still couldn’t use the camera I wanted due to not being able to log in to it to get a snapshot through Mycodo (command works fine through a browser). I was hoping to use an outdoor IP camera in the high humidity grow room (Mycodo pi will be in the lab). Do you have a suggestion for a good “waterproof” remote camera setup?

1 Like