python3堆栈,Python3.4错误-无法作为共享对象要求启用可执行堆栈:无效的参数

I've been trying to install OpenCV in a Bash on Windows (Windows Subsystem for Linux, wsl) environment and it's been proving very difficult.

I think I'm getting very close, but upon entering python, import cv2 gives the following error:

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

How do I enable the library to execute on the stack?

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

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

However, even though I can successfully download the execstack package, it isn't a recognized command I can run to allow execution on the stack. I suspect this has something to do with Data Execution Prevention, Window's version of Exec-Shield to prevent stack smashing attacks.

But maybe I've just been too close to the problem to figure out what's wrong. Why can't I import this python package? I'm using Python v3.4 and OpenCV compiled from the latest source code (v.3.1).

解决方案

I solved this problem following this:tatsuya-y.hatenablog.com

I use windows bash and install opencv by conda install -c menpo opencv3=3.1.0

then I got this (python 2.7)

>>>import cv2

Traceback (most recent call last):

File "", line 1, in

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

I solve it by execstackcommand

sudo apt-get install execstack

sudo execstack -c $HOME/anaconda2/lib/libopencv_*

Then sudo apt-get install gtk2.0-0

Problem solved! >>> cv2.__version__

'3.1.0'

Remember that the opencv libraries are installed to /usr/local/lib if following the installation instructions online. Thus, the command would be:

sudo execstack -c /usr/local/lib/libopencv_*

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值