问题描述
我已经为Windows安装了Anaconda.它在我的工作PC上,因此我没有管理员权限,因此选择了仅为我"选项.
I have installed Anaconda for Windows. It's on my work PC, so I chose the option "Just for Me" as I don't have admin rights.
Anaconda安装在以下目录中:
Anaconda is installed on the following directory:
c:\Users\huf069\AppData\Local\Continuum\Anaconda
Windows安装程序已将此目录(+ Anaconda \ Scripts目录)添加到系统路径.
The Windows installer has added this directory (+ the Anaconda\Scripts directory) to the System path.
我可以启动Python但尝试运行 x = randn(100,100)
给我一个Name Error: name 'randn' is not defined
但是据我了解,该命令在使用Anaconda时应该可以使用,因为其中包含numpy软件包.
I can launch Python but trying to run x = randn(100,100)
gives me a Name Error: name 'randn' is not defined
,whereas, as I understood, this command should work when using Anaconda, as the numpy package is included.
如果我这样做的话,效果很好
it works fine if I do:
import numpy
numpy.random.randn(100,100)
有人知道会发生什么吗?
Anyone understand what could be happening ?
推荐答案
Anaconda 发行版附带了numpy
软件包,但仍然需要 import 软件包.如果要使用randn()
函数而不必调用完整名称,则可以将其导入到您的本地名称空间:
The Anaconda distribution comes with the numpy
package included, but still you'll need to import the package. If you want to use the randn()
function without having to call the complete name, you can import it to your local namespace:
from numpy.random import randn
x = randn(100,100)
否则,拨打电话numpy.random.randn
是您的出路.
Otherwise, the call numpy.random.randn
is your way to go.
您可能想看看Python的模块"部分教程.
You might want tot take a look at the Modules section of the Python Tutorial.
这篇关于使用Anaconda的软件包不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!