import mxnet 报错

Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:51:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import mxnet
Traceback (most recent call last):
File “”, line 1, in
File “/home/rubick1896/.conda/envs/gluon/lib/python3.6/site-packages/mxnet/init.py”, line 25, in
from . import engine
File “/home/rubick1896/.conda/envs/gluon/lib/python3.6/site-packages/mxnet/engine.py”, line 23, in
from .base import _LIB, check_call
File “/home/rubick1896/.conda/envs/gluon/lib/python3.6/site-packages/mxnet/base.py”, line 111, in
_LIB = _load_lib()
File “/home/rubick1896/.conda/envs/gluon/lib/python3.6/site-packages/mxnet/base.py”, line 103, in _load_lib
lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
File “/home/rubick1896/.conda/envs/gluon/lib/python3.6/ctypes/init.py”, line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: /home/rubick1896/.conda/envs/gluon/lib/python3.6/site-packages/mxnet/libmxnet.so: cannot enable executable stack as shared object requires: Invalid argument

我看了看之前的帖子好像没有一样的错误。conda装的。activate之后conda list和pip list都可以看见mxnet, 版本是1.0.0 post3。在环境里把mx 卸载掉重装还是一样。求解答

我最近也遇到这个问题呢,请问你是怎么解决的~谢谢

两位方便汇报下环境信息吗? 跑这个脚本把输出贴过来就行

1赞

好的,谢谢 。信息如下

  lin@DESKTOP-I77KQ09:~/gluon-tutorials-zh$ python test.py
----------Python Info----------
Version      : 3.6.3
Compiler     : GCC 7.2.0
Build        : ('default', 'Nov 20 2017 20:41:42')
Arch         : ('64bit', '')
------------Pip Info-----------
Version      : 9.0.1
Directory    : /home/lin/miniconda3/lib/python3.6/site-packages/pip
----------MXNet Info-----------
Hashtag not found. Not installed from pre-built package.
----------System Info----------
Platform     : Linux-4.4.0-43-Microsoft-x86_64-with-debian-stretch-sid
system       : Linux
node         : DESKTOP-I77KQ09
release      : 4.4.0-43-Microsoft
version      : #1-Microsoft Wed Dec 31 14:42:53 PST 2014
----------Hardware Info----------
machine      : x86_64
processor    : x86_64
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                8
On-line CPU(s) list:   0-7
Thread(s) per core:    2
Core(s) per socket:    4
Socket(s):             1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 158
Model name:            Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Stepping:              9
CPU MHz:               2801.000
CPU max MHz:           2801.0000
BogoMIPS:              5602.00
Virtualization:        VT-x
Hypervisor vendor:     vertical
Virtualization type:   full
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave osxsave avx f16c rdrand
----------Network Test----------
Setting timeout: 10
Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0738 sec, LOAD: 1.4489 sec.
Timing for Gluon Tutorial(en): http://gluon.mxnet.io, DNS: 0.4136 sec, LOAD: 1.0121 sec.
Timing for Gluon Tutorial(cn): https://zh.gluon.ai, DNS: 0.0399 sec, LOAD: 2.1495 sec.
Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0509 sec, LOAD: 1.7850 sec.
Timing for PYPI: https://pypi.python.org/pypi/pip, DNS: 0.0421 sec, LOAD: 1.2556 sec.
Timing for Conda: https://repo.continuum.io/pkgs/free/, DNS: 0.0401 sec, LOAD: 1.0550 sec.

麻烦检查是否启用了venv
如若启用了激活即可

再虚拟机上重新装了一遍没啥问题。
WIN10 的Ubuntu子系统反正是不行了。
就用虚拟机学习吧~谢谢您了

这个问题后来解决了
sudo apt-get install execstack
sudo execstack -c $HOME/anaconda2/lib/libopencv_*

这样就可以了,似乎是wsl的锅,所以也不知道应不应该甩给你们。。。
话说这个方法也是当时看到有人装opencv有同样的错误,死马当活马医的。
就目前来看,使用一切正常

1赞

刚刚终于试出来了,尝试着楼上的发的方法改的。
sudo apt-get install execstack
sudo execstack -c $HOME/anaconda3/lib/python3.6/site-packages/mxnet/libmxnet.so
主要是找到这个libmxnet.so的位置

1赞

我新搭的环境也是import报错,用你的脚本跑出来后结果如下,能否帮忙看下问题:

Name                                     

Intel® Core™ i5-9400 CPU @ 2.90GHz

----------Python Info----------
Version : 3.6.10
Compiler : MSC v.1916 64 bit (AMD64)
Build : (‘default’, ‘Mar 23 2020 17:58:33’)
Arch : (‘64bit’, ‘WindowsPE’)
------------Pip Info-----------
Version : 20.0.2
Directory : D:\softwares\Anaconda\envs\gluon\lib\site-packages\pip
----------MXNet Info-----------
Traceback (most recent call last):
File “t.py”, line 95, in check_mxnet
import mxnet
File “D:\softwares\Anaconda\envs\gluon\lib\site-packages\mxnet_init_.py”, line 31, in
from . import contrib
File “D:\softwares\Anaconda\envs\gluon\lib\site-packages\mxnet\contrib_init_.py”, line 27, in
from . import autograd
File “D:\softwares\Anaconda\envs\gluon\lib\site-packages\mxnet\contrib\autograd.py”, line 29, in
from …ndarray import NDArray, zeros_like, GRAD_REQ_MAP
File "D:\softwares\Anaconda\envs\gluon\lib\site-packages\mxnet\ndarray_init
.py", line 20, in
from . import internal, contrib, linalg, op, random, sparse, utils, image, ndarray, numpy
File "D:\softwares\Anaconda\envs\gluon\lib\site-packages\mxnet\ndarray\numpy_init
.py", line 23, in
from . import _register
File “D:\softwares\Anaconda\envs\gluon\lib\site-packages\mxnet\ndarray\numpy_register.py”, line 21, in
from …register import _make_ndarray_function
File “D:\softwares\Anaconda\envs\gluon\lib\site-packages\mxnet\ndarray\register.py”, line 270, in
_init_op_module(‘mxnet’, ‘ndarray’, _make_ndarray_function)
File “D:\softwares\Anaconda\envs\gluon\lib\site-packages\mxnet\base.py”, line 600, in _init_op_module
ctypes.byref(plist)))
OSError: exception: access violation writing 0x0000000000000000

----------System Info----------
Platform : Windows-10-10.0.18362-SP0
system : Windows
node : DESKTOP-MK2SFG9
release : 10
version : 10.0.18362
----------Hardware Info----------
machine : AMD64
processor : Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
----------Network Test----------
Setting timeout: 10
Timing for MXNet: https://github.com/apache/incubator-mxnet, DNS: 0.0090 sec, LOAD: 1.7690 sec.
Error open Gluon Tutorial(en): http://gluon.mxnet.io, The read operation timed out, DNS finished in 0.0009057521820068359 sec.
Error open Gluon Tutorial(cn): https://zh.gluon.ai, , DNS finished in 0.0 sec.
Timing for FashionMNIST: https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon/dataset/fashion-mnist/train-labels-idx1-ubyte.gz, DNS: 0.0108 sec, LOAD: 1.2940 sec.
Error open PYPI: https://pypi.python.org/pypi/pip, , DNS finished in 0.009969234466552734 sec.
Error open Conda: https://repo.continuum.io/pkgs/free/, HTTP Error 403: Forbidden, DNS finished in 0.0 sec.
----------Environment----------