Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - Numpy install and import Issue

I've used pip to install the module numpy (sudo pip install numpy).This works fine.

When importing numpy for use in my own module i get several the following errors.

 Traceback (most recent call last):
  File "<pyshell#65>", line 1, in <module>
    import numpy
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/numpy/__init__.py", line 180, in <module>
    from . import add_newdocs
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/numpy/core/__init__.py", line 14, in <module>
    from . import multiarray
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/numpy/core/multiarray.so, 2): Symbol not found: _PyBuffer_Type
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/numpy/core/multiarray.so
  Expected in: flat namespace
 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/numpy/core/multiarray.so

I'm assuming the error has something to do with the multiarray.so file. I've tried turning it off and on (uninstall re install) and adding the where pip initially saves the module to python export path

(export PYTHONPATH="usr/local/lib/python2.7/site-packages")

doesn't seem to work.

Using which python in terminal gives me Python 2.7.6**, however I downloaded python 3.5 off of the site.

like image 367
Ayoub Avatar asked Sep 27 '22 11:09

Ayoub


1 Answers

Issue resolved.

The reason i was having installation issues with pip, was down to the fact (thanks pv) that i was using the command:

"pip install moduleName"

rather than

"pip3.5 install moduleName"

this caused all sorts of complications, because i'm running python 3.5 and the "pip" command is for 2.7.

Thanks again.

like image 110
Ayoub Avatar answered Sep 30 '22 08:09

Ayoub