简体   繁体   中英

Download spacy model and get AttributeError 'NoneType' object has no attribute 'ndarray'

I'm new on python spacy package.

I wanted to download model 'en_core_web_sm' and I get AttributeError.

I searched since 2 days all over the web and I couldn't fix it.

Someone can help me please ?

The code :

import spacy
nlp=spacy.load('en_core_web_sm')

The error :

n = y.shape[0]

AttributeError: 'NoneType' object has no attribute 'ndarray'

I'm using Python 3.6 on conda environment (spyder)

This happened to me once during development and the reason was that for some reason, my code tricked spaCy into thinking I was on GPU. On GPU, spaCy uses cupy instead of numpy – and if cupy is not installed, it defaults to None . It's likely that the code should be calling numpy.ndarray , but it's calling cupy.ndarray , ie None.ndarray , which results in that error.

If you've intended to run spaCy on GPU, make sure it's available and you've installed the correct dependencies for your CUDA version. If you're running spaCy on CPU, here are some things to try:

  • Check what's installed in your environment and make sure you didn't accidentally end up with a half-broken install of cupy or something like that. Also make sure numpy is installed correctly.
  • Unsatisfying answer, but often helps: uninstall spaCy and its dependencies, and reinstall the latest version, ideally in a clean virtual environment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM