完美解决百度aistudio运行gensim的报错:AttributeError: module ‘numpy.random‘ has no attribute ‘default_rng‘

在百度aistudio.baidu.comjupter Notebook中运行gensim出现的如下错误
原始代码

from gensim import corpora,models,similarities

报错

---------------------------------------------------------------------------AttributeError                            Traceback (most recent call last)<ipython-input-2-5a932aa44c88> in <module>
----> 1 from gensim import corpora,models,similarities
      2 import jieba
      3 import pprint
      4 import logging
      5 logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/gensim/__init__.py in <module>
      9 import logging
     10 
---> 11 from gensim import parsing, corpora, matutils, interfaces, models, similarities, utils  # noqa:F401
     12 
     13 
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/gensim/parsing/__init__.py in <module>
      2 
      3 from .porter import PorterStemmer  # noqa:F401
----> 4 from .preprocessing import (remove_stopwords, strip_punctuation, strip_punctuation2,  # noqa:F401
      5                             strip_tags, strip_short, strip_numeric,
      6                             strip_non_alphanum, strip_multiple_whitespaces,
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/gensim/parsing/preprocessing.py in <module>
     24 import glob
     25 
---> 26 from gensim import utils
     27 from gensim.parsing.porter import PorterStemmer
     28 
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/gensim/utils.py in <module>
     60 
     61 #: A default, shared numpy-Generator-based PRNG for any/all uses that don't require seeding
---> 62 default_prng = np.random.default_rng()
     63 
     64 
AttributeError: module 'numpy.random' has no attribute 'default_rng'

解决此问题最好的方法是:
更换平台
使用阿里天池在线编程
https://tianchi.aliyun.com/
完美解决百度aistudio运行gensim的报错:AttributeError: module ‘numpy.random‘ has no attribute ‘default_rng‘_第1张图片

你可能感兴趣的:(解决问题,python,python,bug)