Unable import numpy

866 views
Skip to first unread message

boxfox

unread,
Oct 17, 2017, 2:56:21 AM10/17/17
to Jep Project
I can't import numpy.

jep.JepException: <type 'exceptions.ImportError'>: 
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: /usr/local/lib/python2.7/dist-packages/numpy/core/multiarray.so: undefined symbol: _Py_ZeroStruct

at /usr/local/lib/python2.7/dist-packages/numpy/core/__init__.<module>(__init__.py:26)
at /usr/local/lib/python2.7/dist-packages/numpy/lib/type_check.<module>(type_check.py:11)
at /usr/local/lib/python2.7/dist-packages/numpy/lib/__init__.<module>(__init__.py:8)
at /usr/local/lib/python2.7/dist-packages/numpy/add_newdocs.<module>(add_newdocs.py:13)
at /usr/local/lib/python2.7/dist-packages/numpy/__init__.<module>(__init__.py:142)
at jep.Jep.eval(Native Method)
at jep.Jep.eval(Jep.java:609)
at com.satreci.python.test.Main.main(Main.java:18)

OS : Ubuntu
Python version : 2.7.12
jep version : 3.7.0

Nathan Jensen

unread,
Oct 17, 2017, 2:45:58 PM10/17/17
to Jep Project
It sounds like the numpy build did not go well.  Did you try cleaning and rebuilding it?  If you run python from a terminal and import numpy there, does that work?

--
You received this message because you are subscribed to the Google Groups "Jep Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jep-project+unsubscribe@googlegroups.com.
To post to this group, send email to jep-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jep-project/5f13d73e-6947-494d-ad69-d5946528130d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Andrew Hu

unread,
Dec 20, 2017, 7:10:01 PM12/20/17
to Jep Project
I am also getting the same issue with JEP 3.7.1 with python 3.5.2
I tried reinstalling numpy with pip and I still get the same issue. numpy seems to be working fine in the shell.

Here is my stack trace :
Caused by: jep.JepException: <class 'ImportError'>: 
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: /data/programs/miniconda3/lib/python3.5/site-packages/numpy/core/multiarray.cpython-35m-x86_64-linux-gnu.so: undefined symbol: PyType_GenericNew

at /data/programs/miniconda3/lib/python3.5/site-packages/numpy/core/__init__.<module>(__init__.py:26)
at /data/programs/miniconda3/lib/python3.5/site-packages/numpy/lib/type_check.<module>(type_check.py:11)
at /data/programs/miniconda3/lib/python3.5/site-packages/numpy/lib/__init__.<module>(__init__.py:8)
at /data/programs/miniconda3/lib/python3.5/site-packages/numpy/add_newdocs.<module>(add_newdocs.py:13)
at /data/programs/miniconda3/lib/python3.5/site-packages/numpy/__init__.<module>(__init__.py:142)
at pytx1038116996961105364297833531160086script.<module>(pytx1038116996961105364297833531160086script.py:2)


-----
ps: didnt mean to delete Nathan's reply 

Ben Steffensmeier

unread,
Dec 21, 2017, 8:50:30 AM12/21/17
to Jep Project
Jep comes with a shell script(called jep) that gets installed in the python bin directory. Have you tried running this script and seeing if you are able to import numpy? I suspect that you need to include libpython in LD_PRELOAD because the numpy *.so does not declare its dependency on libpython, if this is your problem then the jep script should work and you can look in the script for an example of how to set LD_PRELOAD. There is also abrief discussion of LD_PRELOAD on the wiki.

Ben

Andrew Hu

unread,
Dec 21, 2017, 2:36:04 PM12/21/17
to Jep Project
Thank you! Setting LD_PRELOAD did it.

蓝梓文

unread,
Apr 1, 2018, 6:41:48 AM4/1/18
to Jep Project
can i ask how to Setting LD_PRELOAD ? 
i did as following . and it don't work

LD_PRELOAD=/usr/local/lib/python3.5

在 2017年12月22日星期五 UTC+8上午3:36:04,Andrew Hu写道:

Ben Steffensmeier

unread,
Apr 1, 2018, 10:42:47 AM4/1/18
to Jep Project
LD_PRELOAD needs to be set to the full path of the libpython shared object, the file name should be similar to libpython3.5m.so. Since the exact path is different depending on your configuration I would recommend shust copy the value out of the jep script that is installed with jep.
Reply all
Reply to author
Forward
0 new messages