Numpy Import Error PyZeroStruct with Python



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”, line 9, in
import numpy as np
File “/usr/local/lib/python2.7/dist-packages/numpy/”, line 142, in
from . import add_newdocs
File “/usr/local/lib/python2.7/dist-packages/numpy/”, line 13, in
from numpy.lib import add_newdoc
File “/usr/local/lib/python2.7/dist-packages/numpy/lib/”, line 8, in
from .type_check import *
File “/usr/local/lib/python2.7/dist-packages/numpy/lib/”, line 11, in
import numpy.core.numeric as _nx
File “/usr/local/lib/python2.7/dist-packages/numpy/core/”, line 14, in
from . import multiarray
ImportError: /usr/local/lib/python2.7/dist-packages/numpy/core/ undefined symbol: _Py_ZeroStruct


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/”, line 25, in
from pandas import hashtable, tslib, lib
ImportError: /usr/local/lib/python2.7/dist-packages/pandas/ undefined symbol: _Py_ZeroStruct

During handling of the above exception, another exception occurred:

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