You are not logged in.
I have a python script I'd like all users on my machine to be able to run. That python script requires the python library "opencv-python" which each user can individually install using "pip install opencv-python", after which point they can use the subject script. However, it would be nice if the opencv-python python package could be installed once at the system level instead. I've read that running "pip install" commands as root is not recommended. I found the arch package python-opencv, which is in the Extra repo, but installing it doesn't seem to actually provide the opencv-python library... Does anyone know what I'm missing / how to do this?
Last edited by tony5429 (2023-04-13 22:13:40)
Offline
It does install it, what exactly makes you think it doesn't? The import/lib to include will be cv2 but that's even documented on the pip FAQ.
Last edited by V1del (2023-04-13 15:58:41)
Offline
The first line of the Python script is "import cv2". It doesn't work if I just have python-opencv installed, but if I run "pip install opencv-python" first, it then does work...
Offline
it should, what error message do you get?
Offline
I'll try it again and post here, when I'm back at my machine. In the meantime, are you saying installing the python-opencv package should...
1. Instantly allow a python script that imports cv2 to work,
or
2. Provide the system the ability for its users to install opencv-python via "pip install opencv-python" (presumably by providing the library locally on the system so pip doesn't have to download it from the internet), after which point a python script that imports cv2 will work?
Offline
option 1.
What does `type -a python` give you? `pacman -Q python python-opencv`?
option 2 is not a thing at all.
Last edited by Scimmia (2023-04-13 17:39:17)
Offline
With python-opencv installed, the "import cv2" command fails:
[tony@mylinux ~]$ pacman -Q python-opencv
python-opencv 4.7.0-7
[tony@mylinux ~]$ python -c 'import cv2'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: libhdf5.so.310: cannot open shared object file: No such file or directory
[tony@mylinux ~]$ type -a python
python is /usr/bin/python
python is /bin/python
Last edited by tony5429 (2023-04-13 21:44:48)
Offline
So this is a simple partial update problem, your hdf5 package is out of date. FULLY update your system, always. Never run pacman -Sy unless someone who really understands the system tells you to. Don't replace system library packages with other versions unless you're going to stay on top of them.
I think that covers the most common causes.
Last edited by Scimmia (2023-04-13 21:54:50)
Offline
Ah! Yes, you were right. I had installed python-opencv without first updating the whole system. Just did a full system upgrade and that fixed it right away. Thanks!
Offline