Python 如何在 Windows 上安装 numpy 和 pandas

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20641199/
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-18 20:54:42  来源:igfitidea点击:

how to install numpy and pandas on windows

pythonnumpyinstallationpandas

提问by googlekid

I'll preface by saying I'm a programming n00b by stack standards. I have experience with data analysis and scripting -- this is what I do professionally at a financial firm -- but I have no idea what I'm doing on the back end.

我先说我是堆栈标准的编程n00b。我有数据分析和脚本编写的经验——这是我在一家金融公司的专业工作——但我不知道我在后端做什么。

I'm trying to start using pandas and python --- moving away from matlab/vba but I can't figure out how to install the pandas library.

我正在尝试开始使用 pandas 和 python --- 远离 matlab/vba,但我不知道如何安装 pandas 库。

When I try to import pandas I get an error that numpy module is not present. I tried to install ezsetup / pip (no idea what this is btw)... and I have no idea where to enter this command$ python get-pip.py

当我尝试导入 Pandas 时,出现 numpy 模块不存在的错误。我试图安装ezsetup / pip(不知道这是什么btw)......我不知道在哪里输入这个命令$ python get-pip.py

Sometimes when I try to import pandasI get an error cannot import name table hashable

有时,当我尝试时import pandas出现错误无法导入可哈希的名称表

I have no idea what any of this means and I am not getting anywhere.

我不知道这意味着什么,而且我一无所获。

Update

更新

Ok I installed anaconda and it seems to be allowing me to import numpy and pandas directly from the console. That being said when I try to write a basic time series and plot it using pandas syntax, i get an error that "series is not defined" as such I'm not sure if it is actually working

好的,我安装了 anaconda,它似乎允许我直接从控制台导入 numpy 和 pandas。话虽如此,当我尝试编写一个基本的时间序列并使用 Pandas 语法绘制它时,我收到一个“未定义序列”的错误,因此我不确定它是否真的有效

  In [1]: import matplotlib.pyplot as plt
  In [2]: ts = Series(randn(1000), index=date_range('1/1/2000', periods=1000))
  In [3]: ts = ts.cumsum()
  In [4]: ts.plot()

回答by dartdog

Best to use a pre-packaged solution, Anacondaor Enthoughtparticularly with windows

最好使用预先打包的解决方案,AnacondaEnthought,尤其是在 Windows 上

回答by MattDMo

The best resource for third-party modules for Windows is Christoph Gohlke's Python Extension Packages for Windowsrepository. Each module is available as a self-extracting .exeinstaller, for use with the python.orgversion of Python - make sure you get the correct installer for your version and architecture.

适用于 Windows 的第三方模块的最佳资源是 Christoph Gohlke 的适用于 Windows存储库的Python 扩展包。每个模块都可作为自解压.exe安装程序使用,与python.org版本的 Python 一起使用 - 确保您获得适合您的版本和体系结构的正确安装程序。

While NumPydoes not require any other packages, pandasdoes, so make sure you get them all. The installation order is not important.

虽然NumPy不需要任何其他软件包,pandas但需要,因此请确保您全部获得。安装顺序并不重要。

The advantages of this resource over a distribution like Anaconda or Enthought is that Dr. Gohlke keeps the packages very up to date, allowing you to run the latest versions of the modules. Additionally, nearly all of the modules have multiple Python versions, while some of the other distributions are only based on Python 2.7.

与 Anaconda 或 Enthought 之类的发行版相比,此资源的优势在于 Gohlke 博士使软件包保持最新状态,从而允许您运行模块的最新版本。此外,几乎所有模块都有多个 Python 版本,而其他一些发行版仅基于 Python 2.7。

The disadvantage is that you need to install each package individually, and there is no package manager for handling dependencies.

缺点是需要单独安装每个包,没有包管理器来处理依赖。

回答by Brian Leach

I had the same headaches and the solution I finally found was to install python xy. This seems to include every package I have ever dreamed of using, and weeks of frustration evaporated almost instantly (related to pandas and many others. It's a great collection of everything you will need. It includes most all of the libraries mentioned above)

我有同样的头痛,我最终找到的解决方案是安装python xy。这似乎包括我梦寐以求使用的每个包,几周的挫折几乎立即消失了(与熊猫和许多其他人有关。这是你需要的一切的一个很好的集合。它包括上面提到的大多数库)

While YMMV, Enthought's Canopy caused issue after issue after issue for my installation. I advise to steer clear.

虽然 YMMV,Enthought 的 Canopy 为我的安装造成了一个又一个问题。我建议避开。

回答by AskMe

Try this: It should work.

试试这个:它应该可以工作。

Go to the location where you have Python (C:\Python34) Run the blow command:

转到你有 Python 的位置 (C:\Python34) 运行blow 命令:

python -m pip install pandas

NUMPY installed automatically after my Pandas installation.

NUMPY 在 Pandas 安装后自动安装。

回答by sandeep rathore

First upgrade pip version using command python -m pip install --upgrade pipafter that just do pip install pandas

首先使用命令python -m pip install --upgrade pip升级 pip 版本,然后执行pip install pandas

Note : - For pandas python-dateutil, numpy, setuptoolsand pytzmodule required.

注意:- 对于Pandas,需要python-dateutil、numpy、setuptoolspytz模块。

回答by Tono Kuriakose

To install pandas for Python 3, you may need to use the python-pandas package. While NumPy does not require any other packages, pandas does, so make sure you get them all. The installation order is not important. ... The disadvantage is that you need to install each package individually, and there is no package manager for handling dependencies.

要为 Python 3 安装 pandas,您可能需要使用 python-pandas 包。虽然 NumPy 不需要任何其他包,但 Pandas 需要,所以请确保您全部获得。安装顺序并不重要。... 缺点是需要单独安装每个包,并且没有包管理器来处理依赖项。

To Install numpy pip install numpy

安装 numpy pip install numpy

To install pandas pip install pandas

安装熊猫 pip install pandas