-
-
Notifications
You must be signed in to change notification settings - Fork 55.7k
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
Cannot import cv2 because unsafe use of relative rpath lib in cv2.so with restricted binary #5447
Comments
Static build should help (via CMake): |
@alalek Thanks a lot! It works for me, but why it works? |
Static build doesn't use RPATH at all |
@alalek I have same question , i have try to add cmake -DBUILD_SHARED_LIBS=OFF ... to build again . it still not work!!! |
@AllanChen Try to cleanup build folder and build from scratch. |
@alalek you mean build again ?? |
Yes, build from scratch and install it again. |
@alalek I need to uninstall opencv on my mac ?? or just remove build folder and rebuild all this . |
Actually, there are not enough details about what have been installed and how you did this. Also you didn't put error message (where path is showed, like Rebuild is not enough in case of path like BTW, you can use |
@alalek Thank you for your comment, i have already rebuild opencv (opencv 3.0) and add path on ~/.bash_profile file. it still not work. this is my install command and setup . About Install
About Setting
About ErrorAfter i import cv lib still got Please Help . |
@AllanChen Thanks! Commands looks good to me! Could you add results of |
@alalek After i run
Run
Run It's very strange, i can run py command but i can not run this script on build folder!!!!! i have already ln the lib to site-packages!!!! something i miss ????? Thanks Again ~~~~~!!!!! |
It is very strange, because I have this output with your commands:
There are no What version of CMake on your machine?
Did you try to cleanup build folder before CMake run?
BTW, You can see exact path of the loaded Python module via |
@alalek Hei man , I think i understand why i can not link this lib ~~~!!!!, i have already run this script on build folder ,it work !!! you have to cp cv2.so to /usr/local/lib folder not rebuild opencv !!!!!
Now this is my code (cp cv2.so lib to /usr/local/lib)
If Not
Thanks for your command ~~~!!! |
This is because of SIP (System Integrity Protection) introduced in El Capitan link. I too faced the same issue and came across this SO link. Basically, the relative path dependencies listed in the shared libs need to be changed to absolute paths. There are huge number of these to be corrected in opencv libraries. You can optionally disable SIP. I preferred to change the links instead and wrote the following python snippet. Change the ABSPATH and LIBPATHS if required. It can be used for other libraries as well. It will create rPathChangeCmd.txt which you can paste in the terminal. It will also create rPathChangeErr.txt in case of any errors. I would suggest check error file (if created) before pasting the commands.
|
The problem arises due to the fact that cv2.so from python site-packages tries to link to a file which can not be found. The reason for it not to be found is because brew installs the file in different locations. Here are the set of steps to resolve this. Find if your
Among other things, it should show a
If this is the case, your
If this file exists, it is the file that needs to be linked. If this file does not exist then (a) Your versions may be different, so change that accordingly. (b) Your opencv installation may have issues. Try uninstalling and reinstalling opencv again
This should correctly link your cv2.so file thus resulting in removing this error. |
@pranny Thanks !!! it's work for me |
In my case, i had to fix the relative path to absolute path fixed the issue
|
I have similar issue here ...
I'm trying to use opencv in tensorflow env following steps from here. but got this error above. |
@arpita8 does
Work? |
its still not working. |
Similar error as @jeannieiscool After following macOS: Install OpenCV 3 and Python 3.5, I got:
Any help would be appreciated! |
Solved this issue: In conda currently, Python 3 doesn't support opencv 3 or 2. So I changed from python 3 to 2. and installed opencv by the following command conda install -c menpo opencv=2.4.11 and did import cv2 and it is working |
I just update my laptop from Yosemite to El Capitan. When I try to use OpenCV-Python, I got this information:
I installed OpenCV3.0 by compiling the source code not using homebrew.
I find a similar problem description from homebrew-opencv: homebrew-science-issues but quite different with this.
What should I do now?
The text was updated successfully, but these errors were encountered: