Python 3.4 error - Unable to enable executable stack as a shared object: Invalid argument

I am trying to install OpenCV in a Bash environment on Windows (Windows subsystem for Linux, wsl) and it was very difficult.

I think I'm very close, but when I import cv2 python import cv2 , the following error appears:

 ImportError: libopencv_core.so.3.1: cannot enable executable stack as shared object requires: Invalid argument 

How to enable the library on the stack?


My OpenCV *opencv*.so* library files are located in /usr/local/lib/ . In a normal Linux environment, I would give libraries the ability to execute on the stack with

 execstack -c /usr/local/lib/*opencv*.so* 

However, although I can successfully download the execstack package, this is not a recognized command that I can run to allow execution on the stack. I suspect this has something to do with the Data Execution Prevention, the Window version of the Exec-Shield, to prevent packetized attacks.

But maybe I was just too close to the problem to understand what happened. Why can't I import this python package? I am using Python v3.4 and OpenCV compiled from the latest source code (v.3.1).

+7
python windows opencv windows-subsystem-for-linux
source share
4 answers

I solved this problem as follows: tatsuya-y.hatenablog.com

I use windows bash and install opencv conda install -c menpo opencv3=3.1.0 then I got this (python 2.7) >>>import cv2 Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: libopencv_ccalib.so.3.1: cannot enable executable stack as shared object requires: Invalid argument

I execstack it with the execstack command

 sudo apt-get install execstack sudo execstack -c $HOME/anaconda2/lib/libopencv_* 

Then sudo apt-get install gtk2.0-0 problem is solved! >>> cv2.__version__ '3.1.0'

Remember that opencv libraries are installed in / usr / local / lib if you follow the installation instructions on the Internet. Thus, the command will:

 sudo execstack -c /usr/local/lib/libopencv_* 
+24
source share

There are many things that simply do not work at the moment, because there are either outstanding system calls (WSL has only partial coverage, only about 70% of system calls are implemented, some of them only partially), or there are no socket modes and options (WSL so far does not support UNIX sockets for datagrams, although it should be available in the next insider build).

If you go into github (BashOnWindows) and submit strace or look for your problem and find a copy of it, this is the best way to get an answer. The Microsoft team working on this project wants to get lots and lots of feedback and bugtesting.

To be clear, I say that you are 100% working on what has not yet been implemented. However, it may be so if you look at the source code for your .so file to disable some of the code using this syscall (since Python is cross-platform, and not all Linux system calls are supported on all * nix operating systems).

+3
source share

I also had the same problem, but I was able to fix it just by reinstalling it

$ sudo apt-get install execstack

and the comment mentioned above in Windows 10 build 14393.479

+1
source share

You can use execstack to install opencv and even import lib. However, to perform video capture, as in cv2.VideoCapture (0), bash for windows will not work. You must install the full distribution.

0
source share

All Articles