简体   繁体   English

使用Anaconda的软件包不起作用

[英]Packages not working, using Anaconda

I have installed Anaconda for Windows. 我已经为Windows安装了Anaconda。 It's on my work PC, so I chose the option "Just for Me" as I don't have admin rights. 它在我的工作PC上,因此我没有管理员权限,因此选择了“ Just for Me”选项。

Anaconda is installed on the following directory: Anaconda安装在以下目录中:

c:\Users\huf069\AppData\Local\Continuum\Anaconda

The Windows installer has added this directory (+ the Anaconda\\Scripts directory) to the System path. Windows安装程序已将此目录(+ Anaconda \\ Scripts目录)添加到系统路径。

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. 我可以启动Python,但是尝试运行x = randn(100,100)会给我一个Name Error: name 'randn' is not defined ,而据我所知,由于包含了numpy软件包,因此该命令在使用Anaconda时应该可以使用。

it works fine if I do: 如果我这样做,它会很好:

import numpy
numpy.random.randn(100,100)

Anyone understand what could be happening ? 有人知道会发生什么吗?

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 我可以启动Python,但是尝试运行x = randn(100,100)会给我一个Name Error: name 'randn' is not defined ,而据我所知,由于使用了numpy软件包,因此该命令在使用Anaconda时应该可以使用

The Anaconda distribution comes with the numpy package included, but still you'll need to import the package. Anaconda发行版附带了numpy软件包,但仍然需要导入该软件包。 If you want to use the randn() function without having to call the complete name, you can import it to your local namespace: 如果要使用randn()函数而不必调用完整名称,则可以将其导入到本地名称空间:

from numpy.random import randn
x = randn(100,100)

Otherwise, the call numpy.random.randn is your way to go. 否则,调用numpy.random.randn是您的理想选择。

You might want tot take a look at the Modules section of the Python Tutorial. 您可能想看看Python教程的“ 模块”部分

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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