我最近使用pip在Windows上更新了numpy并遇到了一个奇怪的问题。更新后,当我从管理员提示符运行python并导入numpy时,它工作正常。但是当我从正常的非管理员提示符导入它时,我收到此错误:
>>> import numpy
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import numpy
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\__init__.py", line 190, in <module>
from . import add_newdocs
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\lib\__init__.py", line 9, in <module>
from .index_tricks import *
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\lib\index_tricks.py", line 12, in <module>
from . import function_base
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\lib\function_base.py", line 2489, in <module>
def corrcoef(x, y=None, rowvar=1, bias=np._NoValue, ddof=np._NoValue):
AttributeError: module 'numpy' has no attribute '_NoValue'
当我再次尝试时,它会变为
>>> import numpy
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import numpy
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\__init__.py", line 190, in <module>
from . import add_newdocs
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\lib\__init__.py", line 9, in <module>
from .index_tricks import *
File "C:\Program Files (x86)\Python 3.5\lib\site-packages\numpy\lib\index_tricks.py", line 6, in <module>
import numpy.core.numeric as _nx
AttributeError: module 'numpy' has no attribute 'core'
所有库文件都在文件系统中,尽管它听起来无法找到numpy.core
。
一个可能相关的事实是python安装在C:\Program Files (x86)\Python 3.5
而不是根目录中。 (这是3.5版本的默认安装位置,但之前引起了一些小问题。)我想知道文件或目录权限是否存在问题?
此外,我尝试重新安装甚至降级回1.10.4(使用二进制文件here并且问题仍然存在,尽管在升级之前它没有出现,我从同一来源安装了它。
关于问题的任何想法?