简体   繁体   中英

Packages not working, using Anaconda

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 is installed on the following directory:

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

The Windows installer has added this directory (+ the Anaconda\\Scripts directory) to the System path.

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 ?

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

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)

Otherwise, the call numpy.random.randn is your way to go.

You might want tot take a look at the Modules section of the Python Tutorial.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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