-1

Here are the methods I have tried:

  1. run "cargo install ndarray", error: specified package ndarray v0.15.1 has no binaries
  2. download, unzip and run "cargo build", "cargo install --path ." from "https://github.com/rust-ndarray/ndarray", error: specified package ndarray v0.15.1 (C:\Users\Administrator\Downloads\ndarray-master) has no binaries
  3. edit "Cargo.toml" with [dependencies] ndarray = {path = "C:/Users/Administrator/Downloads/ndarray-master"}, error: error[E0463]: can't find crate for ndarray

BTW, code is here:

extern crate ndarray;

fn main() {
    println!("Hello, world!");
}

Any help is appreciated. Thank you in advance.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
cmjdxy
  • 396
  • 1
  • 2
  • 15
  • Put `ndarray = "*"` in the dependencies in `Cargo.toml`. Just like any other dependency. – Jmb Apr 14 '21 at 06:41
  • @Jmb Thanks for the response. Yet I haven't installed the crate. Can you help me with the installation? – cmjdxy Apr 14 '21 at 07:07

1 Answers1

2

You don't need to install crates in Rust. You simply declare them in the project's Cargo.toml file:

[dependencies]
ndarray = "0.15.1"

When you then build your project, cargo will download and build the needed crates on-the-fly. See more here.

Emoun
  • 2,297
  • 1
  • 13
  • 20
  • Thanks for the response and it works! I thought "cargo install" was something like "pip install" and believed I had to install a library first. – cmjdxy Apr 14 '21 at 07:17
  • `cargo install` is for installing executable crates, i.e., crates that are complete programs [like `ripgrep`](https://crates.io/crates/ripgrep). It is not used for adding library crates (like `ndarray`) to a project. – Emoun Apr 14 '21 at 07:19