Numpy Import Error PyZeroStruct with Python

python

#1

I switched to Python 3 and am getting this error when I import numpy and am not sure why. Do I have to change a path to import Python 3 modules?

Traceback (most recent call last):
File “/home/ubuntu/workspace/2 lastfm_track_get_info.py”, line 9, in
import numpy as np
File “/usr/local/lib/python2.7/dist-packages/numpy/init.py”, line 142, in
from . import add_newdocs
File “/usr/local/lib/python2.7/dist-packages/numpy/add_newdocs.py”, line 13, in
from numpy.lib import add_newdoc
File “/usr/local/lib/python2.7/dist-packages/numpy/lib/init.py”, line 8, in
from .type_check import *
File “/usr/local/lib/python2.7/dist-packages/numpy/lib/type_check.py”, line 11, in
import numpy.core.numeric as _nx
File “/usr/local/lib/python2.7/dist-packages/numpy/core/init.py”, line 14, in
from . import multiarray
ImportError: /usr/local/lib/python2.7/dist-packages/numpy/core/multiarray.so: undefined symbol: _Py_ZeroStruct


#2

Actually not sure if its a Python 3 issue as I switched back to Python 2 and received this error

Traceback (most recent call last):
File “/usr/local/lib/python2.7/dist-packages/pandas/init.py”, line 25, in
from pandas import hashtable, tslib, lib
ImportError: /usr/local/lib/python2.7/dist-packages/pandas/hashtable.so: undefined symbol: _Py_ZeroStruct

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/ubuntu/workspace/2 lastfm_track_get_info.py”, line 10, in
import pandas as pd
File “/usr/local/lib/python2.7/dist-packages/pandas/init.py”, line 31, in
“the C extensions first.”.format(module))
ImportError: C extension: /usr/local/lib/python2.7/dist-packages/pandas/hashtable.so: undefined symbol: _Py_ZeroStruct not built. If you want to import pandas from the source directory, you may need to run ‘python setup.py build_ext --inplace --force’ to build the C extensions first.