Python 如何在 Mac 上安装 numpy

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37532733/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 19:31:39  来源:igfitidea点击:

how to install numpy on mac

pythonnumpy

提问by Pavan Sangha

I'm trying to install Numpy on my mac so i can practice doing some programming for data science. However i have no idea what i'm doing when it comes to downloading software and btw my knowledge of software instillation in general is terrible (i'm more of a pure mathematician). If it isn't as simple as hit download and it works (as it seemed to do with windows) i'm finding myself getting stuck.

我正在尝试在我的 Mac 上安装 Numpy,以便我可以练习为数据科学做一些编程。但是,我不知道下载软件时我在做什么,顺便说一句,我对软件灌输的知识总体而言很糟糕(我更像是一个纯粹的数学家)。如果它不像点击下载那么简单并且它可以工作(就像 Windows 一样),我发现自己被卡住了。

I have python 3.5.1 downloaded on my mac. So the book i'm going through at the moment when talking about arrays starts by saying >>>import numpy, in the command prompt. Thinking it would just be as easy as that i tried it, but obviously it wasn't that simple because i haven't downloaded it. Anyway then i looked into downloading numpy, i downloaded a folder in my downloads called numpy.1.11.0 and copied and pasted it into my desktop. I went back to the idle and typed >>>import numpy again, and again it didn't work.

我在我的 mac 上下载了 python 3.5.1。因此,当我在谈论数组时,我正在阅读的这本书首先在命令提示符下说 >>>import numpy。认为它会像我尝试的那样简单,但显然它没有那么简单,因为我还没有下载它。无论如何,然后我研究了下载 numpy,我在我的下载中下载了一个名为 numpy.1.11.0 的文件夹,并将其复制并粘贴到我的桌面上。我回到空闲状态并再次输入 >>>import numpy ,它再次不起作用。

I'm so confused as to what to do now, i've looked at some older posts but they haven't helped, i've also downloaded an open source package called anaconda (something mentioned in the other posts) which i think has everything (data science related) on it but i have no idea how to use it. Do i create python scripts in anaconda? Do i create the scripts before and some how run them in anaconda?

我现在不知道该怎么做,我看过一些较旧的帖子,但没有帮助,我还下载了一个名为 anaconda 的开源软件包(其他帖子中提到的内容),我认为它有一切(数据科学相关),但我不知道如何使用它。我在 anaconda 中创建 python 脚本吗?我之前是否创建了脚本以及如何在 anaconda 中运行它们?

I'd really appreciate any help regarding how to get numpy installed or perhaps how to start using python in anaconda (or both). I've found myself getting lost in all the jargon in the other posts, a simple step by step approach i.e "first click this", "then install this" would probably be best suited to me, if anyone knows where i can find instructions in this form i'd very much appreciate it.

我非常感谢有关如何安装 numpy 或如何开始在 anaconda(或两者)中使用 python 的任何帮助。我发现自己迷失在其他帖子中的所有行话中,一个简单的分步方法,即“先点击这个”,“然后安装这个”可能最适合我,如果有人知道我在哪里可以找到说明以这种形式,我将非常感激。

Thanks for the help!

谢谢您的帮助!

Edit: Thanks to everyone for the help it has been great, in particular i tried pip3 install numpy in the command line. Now i can import numpy in the python idle. If i want to use it in a script file (i'm using text wrangler for this) would i just import numpy as usual?

编辑:感谢大家的帮助,它很棒,特别是我在命令行中尝试了 pip3 install numpy。现在我可以在 python idle 中导入 numpy。如果我想在脚本文件中使用它(我为此使用了 text wrangler),我会像往常一样导入 numpy 吗?

In addition i started playing around with anaconda and using the spyder package this also let's me run python scripts and allows me to import numpy.

此外,我开始使用 anaconda 并使用 spyder 包,这也让我可以运行 python 脚本并允许我导入 numpy。

回答by Ryan

Go to your terminal and run the following command:

转到您的终端并运行以下命令:

pip3 install numpy

If that gives you permission or IO errors try using sudo

如果这给了您权限或 IO 错误,请尝试使用 sudo

sudo pip3 install numpy