Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No package 'opencv' found #2280

Open
ANU197 opened this issue Sep 3, 2020 · 32 comments
Open

No package 'opencv' found #2280

ANU197 opened this issue Sep 3, 2020 · 32 comments

Comments

@ANU197
Copy link

ANU197 commented Sep 3, 2020

(tutorial-env) apdebian@ap:~/Music/darknet$ make
chmod +x *.sh
g++ -std=c++11 -std=c++11 -Iinclude/ -I3rdparty/stb/include -DOPENCV pkg-config --cflags opencv4 2> /dev/null || pkg-config --cflags opencv -Wall -Wfatal-errors -Wno-unused-result -Wno-unknown-pragmas -fPIC -Ofast -DOPENCV -c ./src/image_opencv.cpp -o obj/image_opencv.o
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
./src/image_opencv.cpp:16:10: fatal error: opencv2/core/version.hpp: No such file or directory
16 | #include <opencv2/core/version.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:174: obj/image_opencv.o] Error 1
Screenshot from 2020-09-03 17-33-08

i aleady download opencv from github

@AnhPC03
Copy link

AnhPC03 commented Sep 7, 2020

Had you changed the 2nd line of the Makefile to: OPENCV=1?

@ANU197
Copy link
Author

ANU197 commented Sep 7, 2020

Yes, i changed in Makefile

@xwr96
Copy link

xwr96 commented Sep 15, 2020

I also meet the same problem with you!do you solve?

@AnhPC03
Copy link

AnhPC03 commented Sep 16, 2020

@ANU197 @xwr96 what was your opencv version?
Had you try sudo apt install libopencv-dev?

@xwr96
Copy link

xwr96 commented Sep 16, 2020

@ANU197 @xwr96 what was your opencv version?
Had you try sudo apt install libopencv-dev?

my opencv version is 4.1.2. because I already install the opencv4, so I do not try 'sudo apt install libopencv-dev, do I try?

@AnhPC03
Copy link

AnhPC03 commented Sep 16, 2020

@xwr96 Yes, You should try. Then let me know the result.

@xwr96
Copy link

xwr96 commented Sep 16, 2020

@AnhPC03 I did, it response "libopencv-dev is already the newest version (3.2.0+dfsg-4ubuntu0.1).
0 to upgrade, 0 to newly install, 0 to remove and 135 not to upgrade." and it also doesn't work. the error message is :
No package 'opencv' found
./src/image_opencv.cpp:5:30: fatal error: opencv2/opencv.hpp: No such file or directory
compilation terminated.
Makefile:86: recipe for target 'obj/image_opencv.o' failed
make: *** [obj/image_opencv.o] Error 1

@AnhPC03
Copy link

AnhPC03 commented Sep 16, 2020

Had you changed the two lines of the Makefile to: OPENCV=1 and GPU=1?
Then run make command?
After you change anything, just run make

@xwr96
Copy link

xwr96 commented Sep 16, 2020

@AnhPC03 Yes. I already changed, but it error. In fact, it can run properly. but I think it use CPU,not a GPU, because it cost 21seconds

@AnhPC03
Copy link

AnhPC03 commented Sep 16, 2020

if it can run properly but on CPU, change in Makefile to GPU=1 and run make again. I had ran it on GPU.
But opencv was still error?

@xwr96
Copy link

xwr96 commented Sep 16, 2020

if it can run properly but on CPU, change in Makefile to GPU=1 and run make again. I had ran it on GPU.

when I change the 'GPU'=1, opencv=1, it cause error above what I said. So I confused

@AnhPC03
Copy link

AnhPC03 commented Sep 16, 2020

What will be output when you run pkg-config --cflags opencv?

@xwr96
Copy link

xwr96 commented Sep 16, 2020

@AnhPC03 the output is
Package opencv was not found in the pkg-config search path. Perhaps you should add the directory containing opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
`

@AnhPC03
Copy link

AnhPC03 commented Sep 16, 2020

@xwr96 check your opencv package, if exist, uninstall it. Then run pip install opencv-python.
Let me know the result after you run pkg-config --cflags opencv again

@ck196
Copy link

ck196 commented Sep 16, 2020

@xwr96 When you install OpenCV manually, you should install with release.

cmake --build . --config Release

And libopencv will be installed to /usr/lib

So, confirm it by:

pkg-config --modversion opencv

@xwr96
Copy link

xwr96 commented Sep 16, 2020

@ck196 it turns out
Error: could not load cache

@xwr96
Copy link

xwr96 commented Sep 16, 2020

@xwr96 check your opencv package, if exist, uninstall it. Then run pip install opencv-python.
Let me know the result after you run pkg-config --cflags opencv again

ok, I have a try. Thanks!

@essanhaji
Copy link

essanhaji commented Oct 15, 2020

Hi dear,
i have same problem and i save it with installing libopencv-dev and remake again,
if you are using a CPU like me make sur to set GPU to 0 and make opencv to 1 in makefile,

GPU=0
OPENCV=1

sudo apt-get install libopencv-dev
make

i hop you solve it

@ABHIINAV12
Copy link

I have same problem, tried everything above. What to set in path by the way ?

@cgironda
Copy link

Thanks to the comments of @AnhPC03 and @essanhaji, I solved my problem on a Droplet created in "Digitalocean".
Before using the make command, I made the installation below to avoid problems during the compilation process.

sudo apt-get install g++

I hope this would help to anyone.

@vivek9patel
Copy link

I just had the same problem,
it can be solved just by installing OpenCV using,

sudo apt install libopencv-dev

@Batuhanakd
Copy link

I just had the same problem,
it can be solved just by installing OpenCV using,

sudo apt install libopencv-dev

That applies to me too. I just run sudo apt install libopencv-dev

@himanshuknegi
Copy link

@xwr96 Yes, You should try. Then let me know the result.

it is working

@zarraozaga
Copy link

sudo apt install libopencv-dev will install opencv in pkg-config --cflags opencv4 but not in pkg-config --cflags opencv. Anyone
knows how to fix this?

@ganesh15220
Copy link

I just had the same problem,
it can be solved just by installing OpenCV using,
sudo apt install libopencv-dev

That applies to me too. I just run sudo apt install libopencv-dev

This is working for me

@janbertoo
Copy link

Hi all, on my local machine (ubuntu) I had the same error (even though I already had opencv installed using pip) which was solved with installing libopencv-dev using apt install.

However, now I am trying to run the code on another machine (also ubuntu) in which I only have a virtual environment. When I install libopencv-dev using apt install I will install it system-wide, which might mess up other users of the machine.

So now I tried "conda install -c anaconda libopencv" as conda is supposed to install it only on my virtual environment. However, after succesfull installation (now both with pip and conda) it still gives me the same error: "No package 'opencv' found" when I am trying to 'make' darknet.

Can someody help?

@robsss
Copy link

robsss commented Mar 11, 2022

@zarraozaga maybe we could shift to another repo, like AlexeyAB's repo.

@raisinbl
Copy link

I just found out that the OpenCV package that installed from sudo apt install libopencv-dev is opencv4 which is located in \usr\include. And under that opencv4 folder, guess what we have? Yes, the opencv2 folder.

So to overcome this problem when you change the OPENCV= 1 on Makefile and show up **fatal error** opencv2/core/version.hpp: No such file or directory

All the thing you need to do is just change on the line 45, 46

45 LDFLAGS+= `pkg-config --libs opencv` -lstdc++
46 COMMON+= `pkg-config --cflags opencv` 

to

LDFLAGS+= `pkg-config --libs opencv4` -lstdc++
COMMON+= `pkg-config --cflags opencv4` 

Conclusion: Just install OpenCV by sudo apt-get install libopencv-dev, change opencv on line 45, 46 on Makefile to opencv4.

@happyamyhope
Copy link

I just found out that the OpenCV package that installed from sudo apt install libopencv-dev is opencv4 which is located in \usr\include. And under that opencv4 folder, guess what we have? Yes, the opencv2 folder.

So to overcome this problem when you change the OPENCV= 1 on Makefile and show up **fatal error** opencv2/core/version.hpp: No such file or directory

All the thing you need to do is just change on the line 45, 46

45 LDFLAGS+= `pkg-config --libs opencv` -lstdc++
46 COMMON+= `pkg-config --cflags opencv` 

to

LDFLAGS+= `pkg-config --libs opencv4` -lstdc++
COMMON+= `pkg-config --cflags opencv4` 

Conclusion: Just install OpenCV by sudo apt-get install libopencv-dev, change opencv on line 45, 46 on Makefile to opencv4.

this does not work for me.

@Thakay
Copy link

Thakay commented Aug 28, 2022

I just found out that the OpenCV package that installed from sudo apt install libopencv-dev is opencv4 which is located in \usr\include. And under that opencv4 folder, guess what we have? Yes, the opencv2 folder.

So to overcome this problem when you change the OPENCV= 1 on Makefile and show up **fatal error** opencv2/core/version.hpp: No such file or directory

All the thing you need to do is just change on the line 45, 46

45 LDFLAGS+= `pkg-config --libs opencv` -lstdc++
46 COMMON+= `pkg-config --cflags opencv` 

to

LDFLAGS+= `pkg-config --libs opencv4` -lstdc++
COMMON+= `pkg-config --cflags opencv4` 

Conclusion: Just install OpenCV by sudo apt-get install libopencv-dev, change opencv on line 45, 46 on Makefile to opencv4.

Works but needs C++11 !!!

@edgarcorrea1
Copy link

Hi dear, i have same problem and i save it with installing libopencv-dev and remake again, if you are using a CPU like me make sur to set GPU to 0 and make opencv to 1 in makefile,

GPU=0
OPENCV=1

sudo apt-get install libopencv-dev
make

i hop you solve it

Hi, I have the same problem but in mac, you know how to solve it, it mac is not posible to use apt-get, but the issue is the same

@AlanTuring42
Copy link

Hi, I have the same problem but in mac, you know how to solve it, it mac is not posible to use apt-get, but the issue is the same

Check here #2505 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests