gpt4 book ai didi

python - Numpy 导入抛出 AttributeError : 'module' object has no attribute 'core'

转载 作者:太空狗 更新时间:2023-10-29 21:14:41 27 4
gpt4 key购买 nike

import numpy as np
File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 57, in <module>
from numpy.testing import Tester
File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/testing/__init__.py", line 14, in <module>
from .utils import *
File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/testing/utils.py", line 15, in <module>
from tempfile import mkdtemp
File "/usr/lib/python2.7/tempfile.py", line 35, in <module>
from random import Random as _Random
File "/home/anirrudh/OMSCS/Courses/ML4T/ml4t/mc3_p2/random.py", line 5, in <module>
import matplotlib.pyplot as plt
File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 122, in <module>
from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label
File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/matplotlib/cbook.py", line 33, in <module>
import numpy.ma as ma
File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/ma/__init__.py", line 44, in <module>
from . import core
File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/ma/core.py", line 30, in <module>
import numpy.core.umath as umath
AttributeError: 'module' object has no attribute 'core'

我正在使用 Ubuntu 14.04。我尝试重新安装 numpy,创建了一个新的 virtualenv,但它没有帮助。我在 virtualenv 之外也遇到了同样的错误。它突然停止工作。刚才还好好的。

最佳答案

(代表 OP 发布答案)

更新:已解决。

我为我的一个名为 random.py 的项目创建了一个 python 文件,当导入 numpy 时,它调用的是这个文件而不是它自己的库文件,因此导致错误。我不得不删除/重命名我创建的 random.py 并解决了这个问题。

关于python - Numpy 导入抛出 AttributeError : 'module' object has no attribute 'core' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33991993/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com