8

I was wondering if anyone had this issue when running spark and trying to import numpy. Numpy imports properly in a standard notebook, but when I try importing it via a notebook running spark, I get this error. I have the most recent version of numpy and am running the most recent anaconda python 3.6.

Thanks!

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
 in ()
----> 1 import numpy

/Users/michaelthomas/anaconda/lib/python3.6/site-packages/numpy/__init__.py in ()
    144         return loader(*packages, **options)
    145 
--> 146     from . import add_newdocs
    147     __all__ = ['add_newdocs',
    148                'ModuleDeprecationWarning',

/Users/michaelthomas/anaconda/lib/python3.6/site-packages/numpy/add_newdocs.py in ()
     11 from __future__ import division, absolute_import, print_function
     12 
---> 13 from numpy.lib import add_newdoc
     14 
     15 ###############################################################################

/Users/michaelthomas/anaconda/lib/python3.6/site-packages/numpy/lib/__init__.py in ()
      6 from numpy.version import version as __version__
      7 
----> 8 from .type_check import *
      9 from .index_tricks import *
     10 from .function_base import *

/Users/michaelthomas/anaconda/lib/python3.6/site-packages/numpy/lib/type_check.py in ()
      9            'common_type']
     10 
---> 11 import numpy.core.numeric as _nx
     12 from numpy.core.numeric import asarray, asanyarray, array, isnan, \
     13                 obj2sctype, zeros

AttributeError: module 'numpy' has no attribute 'core'
3
  • 2
    have you by any chance named a script numpy.py in your working directory? Commented Apr 24, 2017 at 1:47
  • @juanpa.arrivillaga, no, it was just an untitled Jupyter notebook. Commented May 9, 2017 at 2:12
  • Up. Any thoughts? Commented Jun 20, 2017 at 14:20

5 Answers 5

7

I was having the same issue and I tried upgrading the numpy package using pip and it has got resolved.

pip install --upgrade numpy

(base) C:\Users\Mohanavelu>pip install --upgrade numpy

Collecting numpy
  Downloading https://files.pythonhosted.org/packages/53/d1/2499797c88de95ea3239ad7f6e6a47895fe51aad1aa2a116f50ec9e0ee74/numpy-1.15.0-cp36-none-win_amd64.whl (13.5MB)
    100% |████████████████████████████████| 13.5MB 1.6MB/s
Installing collected packages: numpy
  Found existing installation: numpy 1.14.0
    Uninstalling numpy-1.14.0:
      Successfully uninstalled numpy-1.14.0
Successfully installed numpy-1.15.0
Sign up to request clarification or add additional context in comments.

2 Comments

After upgrade, the NumPy restart the IDE
this fixed a similar problem of mine: xgboost AttributeError: module 'numpy.core' has no attribute 'numerictypes'
0

Apart from upgrading and re-installing, sometimes it is caused by your Pandas. It might have dependency on older numpy so you may have to upgrade or reinstall pandas if upgrading numpy alone didn't resolve your problem.

Comments

0

Easy Solution:

In Pycharm: Just go to settings -> Build-Execution-Deployment -> Python Debugger

Than change the PyQT Compatibility from Auto to the on you Use. In my case PyQT6.

And it works.

LG

Comments

0

I was also having the same issue. Before, I installed the numpy through conda install numpy.

I uninstalled numpy which I installed through conda.

conda uninstall numpy

Then I installed through pip installation and it got resolved for me.

pip install numpy

May be, this step will help you out to resolved if you are anaconda python.

Comments

-1

Probably not a solution for you. But restarting kernel of my Jupyter notebook fixed this issue for me.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.