windows查看堆栈信息_在Windows上设置PyData堆栈

windows查看堆栈信息

The speed of modern electronic devices allows us to crunch large amounts of data at home. However, these devices require the right software in order to reach peak performance. Luckily, it’s now easier than ever to set up your own data science environment.

现代电子设备的速度使我们能够在家中处理大量数据。 但是,这些设备需要正确的软件才能达到最佳性能。 幸运的是,现在设置自己的数据科学环境比以往任何时候都容易。

One of the most popular stacks for data science is PyData, a collection of software packages within Python. Python is one of the most common languages in data science, largely thanks to its wide selection of user-made packages.

数据科学最受欢迎的堆栈之一是PyData ,它是Python内的软件包的集合。 Python是数据科学中最常用的语言之一,这在很大程度上要归功于它对用户制作的软件包的广泛选择。

In this tutorial, we’ll show you how to set up a fully functional PyData stack on your local Windows machine. This will give you full control over your installed environment and give you a first taste of what you’ll need to know when setting up more advanced configurations in the cloud. To install the stack, we’ll be making use of Anaconda, a popular Python distribution released by Continuum Analytics. It contains all the packages and tools to get started with data science, including Python packages and editors.

在本教程中,我们将向您展示如何在本地Windows计算机上设置功能齐全的PyData堆栈。 这将使您完全控制已安装的环境,并使您初步了解在云中设置更多高级配置时需要了解的知识。 要安装堆栈,我们将使用Anatuonda (一种由Continuum Analytics发布的流行Python发行版)。 它包含数据科学入门的所有软件包和工具,包括Python软件包和编辑器。

By default, Anaconda includes over 100 packages with over 600 additional packages available through the included package manager. Some of the most notable packages are the following:

默认情况下,Anaconda包含100多个软件包,并通过随附的软件包管理器提供600多个其他软件包。 以下是一些最著名的软件包:

  • NumPy: A popular linear algebra package that greatly facilitates and accelerates numerical computations in Python.
  • SciPy: Includes functions for common mathematical operations, such as integration, derivation and numerical optimization, which can be used with NumPy objects.
  • Pandas: Builds on NumPy to work flexibly with labeled data and provides easy access to various analysis and visualization routines.
  • Scikit-learn: The most popular Python machine learning library, includes many popular models to perform predictive analytics, as well as pre- and post-processing of data.
  • StatsModels: Similar to scikit-learn, aimed at performing classical descriptive statistics.
  • Matplotlib: A popular generic plotting library including line, bar, and scatter plots. Can be accessed through pandas.
  • Seaborn: A statistical visualization library building on matplotlib, including plotting of distributions and heatmaps.
  • Basemap: A library enabling the plotting of geographical data (i.e. to plot data on maps); also built on matplotlib.
  • NumPy :一种流行的线性代数软件包,极大地促进和加速了Python中的数值计算。
  • SciPy :包括可用于NumPy对象的常用数学运算功能,例如积分,求导和数值优化。
  • Pandas :建立在NumPy上,可灵活处理带标签的数据,并提供对各种分析和可视化例程的轻松访问。
  • Scikit-learn :最流行的Python机器学习库,包括许多流行的模型来执行预测分析以及数据的预处理和后处理。
  • StatsModels :类似于scikit-learn,旨在执行经典的描述性统计。
  • Matplotlib :一种流行的通用绘图库,包括线图,条形图和散点图。 可以通过熊猫进入。
  • Seaborn :基于matplotlib的统计可视化库,包括绘制分布图和热图。
  • 底图(Basemap) :一个库,可以绘制地理数据(即在地图上绘制数据); 也建立在matplotlib上。

A full list of included packages can be found here.

包含软件包的完整列表可以在这里找到。

Besides Python packages, various desktop applications are also included. Others, such as RStudio, can be installed with a single click. The currently preinstalled programs are:

除Python软件包外,还包括各种桌面应用程序。 只需单击即可安装RStudio等其他工具。 当前预安装的程序是:

  • Jupyter Notebook: A web server application that allows you to interactively run Python and visualize your data within your browser.
  • Jupyter Qt console: Similar to jupyter notebook, allows you to run python interactively and visualize your data, but from a command-line window.
  • Spyder: A more advanced Python editor that includes features such as interactive testing, debugging, and introspection.
  • Jupyter Notebook :一个Web服务器应用程序,它使您可以交互式运行Python并在浏览器中可视化数据。
  • Jupyter Qt控制台 :类似于jupyter笔记本,它允许您从命令行窗口交互式地运行python并可视化数据。
  • Spyder :一种更高级的Python编辑器,其中包括交互式测试,调试和自省等功能。

使用Anaconda安装PyData堆栈 (Installing the PyData stack with Anaconda)

Setting up PyData with Anaconda is usually a painless process. The standard distribution contains the most commonly-used packages and requires little custom configuration. Other packages can be easily added using the package manager. In the following sections, we’ll walk you through the installation process.

使用Anaconda设置PyData通常很容易。 标准发行版包含最常用的软件包,几乎不需要自定义配置。 其他软件包可以使用软件包管理器轻松添加。 在以下各节中,我们将引导您完成安装过程。

选择安装程序 (Choosing your installer)

First, you’ll have to download the appropriate version of Anaconda from their download page. Installers are available for Windows, macOS and Linux. While we’ll focus on the installation procedure on Windows, much of the information found in this article will work on other operating systems. Different installers are also available for different Python versions. In this tutorial, we’ll be using the recommended latest version of Python: 3.6.

首先,您必须从其下载页面下载相应版本的Anaconda。 安装程序适用于Windows,macOS和Linux。 尽管我们将重点介绍Windows上的安装过程,但本文中发现的许多信息都可以在其他操作系统上使用。 不同的安装程序也可用于不同的Python版本。 在本教程中,我们将使用推荐的最新版本的Python:3.6。

You can also choose between a 32-bit and 64-bit version of the distribution. Typically 64-bit is recommended as this will allow you to use more than 3.5 GB of memory, an amount commonly consumed when working with big data. You should only download the 32-bit package if you’re running an old computer that doesn’t support 64-bit.

您还可以在发行版的32位和64位版本之间进行选择。 通常建议使用64位,因为这将允许您使用超过3.5 GB的内存,这是处理大数据时通常消耗的容量。 如果您运行的是不支持64位的旧计算机,则仅应下载32位软件包。

安装过程 (The installation process)

  1. Once the installer is downloaded, simply run it by double-clicking. The installer will open the window shown in the image below; click Next.
  1. 下载安装程序后,只需双击即可运行它。 安装程序将打开下图所示的窗口; 点击下一步。
  1. A welcome screen will appear with the license agreement for Anaconda. Once you’re comfortable, accept the license by clicking I Agree.
  1. 将出现一个欢迎屏幕,其中包含Anaconda的许可协议。 感觉舒适后,请单击“我同意”接受许可。
  1. The next window will let you choose to install just for yourself or for all users. Choose the former unless you plan to access Anaconda from other user accounts on the same computer. After making your choice, click Next.
  1. 在下一个窗口中,您可以选择只为自己或为所有用户安装。 除非您打算从同一台计算机上的其他用户帐户访问Anaconda,否则请选择前者。 做出选择后,单击“下一步”。
  1. Now you can choose where to install Anaconda. The default path will be fine in most cases. If you live in a non-English speaking country, ensure the path does not contain any special characters. Once you have selected the appropriate path, click Next.
  1. 现在,您可以选择在哪里安装Anaconda。 在大多数情况下,默认路径都可以。 如果您居住在非英语国家,请确保路径中不包含任何特殊字符。 选择适当的路径后,单击“下一步”。
  1. The next page allows you to customize the integration options with Windows. Under normal circumstances, the default option should be fine. If you have another Python version you would like to keep as default then the bottom checkbox can be unticked. The first radio button modifies your global PATH; selecting it is generally not recommended unless you know what you’re doing. Finally, click Install and the installation process will begin.
  1. 下一页允许您自定义Windows的集成选项。 通常情况下,默认选项应该可以。 如果您要使用其他Python版本,请保留默认值,然后取消选中底部的复选框。 第一个单选按钮修改您的全局PATH; 除非您知道自己在做什么,否则通常不建议选择它。 最后,单击“安装”,安装过程将开始。

使用Anaconda Navigator探索Anaconda (Exploring Anaconda with Anaconda Navigator)

Once the installation finishes, there will be an Anaconda folder in your start menu. Inside you will find a shortcut to Anaconda Navigator, which serves as a portal to the various software packages and functions included in the distribution. It will allow you to quickly and easily manage your packages, projects, and environments. More advanced configuration can be performed through the Anaconda prompt, a command-line interface which we will discuss in the next section.

安装完成后,开始菜单中将存在Anaconda文件夹。 在内部,您可以找到Anaconda Navigator的快捷方式,该快捷方式可作为分发中包含的各种软件包和功能的门户。 它使您可以快速轻松地管理软件包,项目和环境。 可以通过Anaconda提示符执行更高级的配置,Anaconda提示符是一个命令行界面,我们将在下一部分中进行讨论。

On the left side, you can see the five main tabs: Home, Environments, Projects, Learning, and Community.

在左侧,您可以看到五个主要标签:“主页”,“环境”,“项目”,“学习”和“社区”。

(Home)

The home tab lists the applications currently installed through Anaconda. By default, these are Jupyter Notebook, Qt Console, and Spyder. Home also lets you install the visualization software GlueViz; data mining framework Orange; and, for those interested in R, RStudio. All applications can be installed, updated, or removed through the settings icon in the top right of each application box. You can also change the application to a specific version for compatibility reasons.

主页选项卡列出了当前通过Anaconda安装的应用程序。 默认情况下,这些是Jupyter Notebook,Qt Console和Spyder。 主页还允许您安装可视化软件GlueViz; 数据挖掘框架Orange; 对于那些对R感兴趣的人,RStudio。 可以通过每个应用程序框右上角的设置图标来安装,更新或删除所有应用程序。 您也可以出于兼容性原因将应用程序更改为特定版本。

环境环境 (Environments)

Anaconda enables you to manage your Python installation through environments. Each environment runs a specific Python version, with a limited number of packages. The specific version of the packages can be chosen during installation and more packages can be added to the environment at any time. Using environments allows you to run your Python code in a safe way, by reducing the chance of conflicts between packages. They can also be transferred between computers. By default there is only the root environment, running the latest Python version with all Anaconda packages included. More details on advanced management of environments using the Anaconda prompt will be given further in the post.

Anaconda使您可以通过环境管理Python安装。 每个环境都运行一个特定的Python版本,并带有数量有限的软件包。 可以在安装过程中选择特定版本的软件包,并且可以随时将更多软件包添加到环境中。 使用环境可以减少包之间发生冲突的机会,从而以安全的方式运行Python代码。 它们也可以在计算机之间传输。 默认情况下,只有根环境,运行包含所有Anaconda软件包的最新Python版本。 使用Anaconda提示对环境进行高级管理的更多详细信息将在帖子中进一步给出。

专案 (Projects)

Would you like to share your personal projects with other users? With Anaconda Projects you can share them in the cloud and automate the deployment process. This includes the downloading of files, installation of packages, as well as setting environment variables and running additional files on the platforms of your choice.

您想与其他用户共享您的个人项目吗? 借助Anaconda Projects,您可以在云中共享它们并自动化部署过程。 这包括文件下载,软件包安装以及设置环境变量并在您选择的平台上运行其他文件。

学习 (Learning)

Access to good information is valuable. In this tab, you’ll find a variety of learning resources including links to documentation, videos, training sessions, and webinars. The most important entries are the reference manuals of PyData’s main packages.

获得良好的信息很有价值。 在此选项卡中,您将找到各种学习资源,包括指向文档,视频,培训课程和网络研讨会的链接。 最重要的条目是PyData主要软件包的参考手册。

The community tab is there to help you reach out. It provides an overview of future events such as conferences, as well as links to various developer forums and blogs where you can get help from other PyData users.

社区标签在那里可以帮助您伸出援手。 它概述了未来的事件,例如会议,以及指向各种开发者论坛和博客的链接,您可以从中获得其他PyData用户的帮助。

Finally, in the top right corner, you can log in to the Anaconda Cloud where users can share packages, notebooks, projects and environments.

最后,您可以在右上角登录Anaconda Cloud,用户可以在其中共享软件包,笔记本,项目和环境。

Anaconda Prompt的高级管理 (Advanced management with the Anaconda Prompt)

While the Navigator provides good basic functionality, advanced package management is best performed through the command-line. Anaconda provides a special command prompt, Anaconda Prompt, which ensures all the necessary environment variables are properly set. We’ll be focusing on managing environments and packages with the conda command. If you’d like to learn more about the Windows command prompt, many tutorials are available online.

尽管导航器提供了良好的基本功能,但最好通过命令行执行高级软件包管理。 Anaconda提供了一个特殊的命令提示符Anaconda Prompt,可确保正确设置所有必需的环境变量。 我们将专注于使用conda命令管理环境和软件包。 如果您想了解有关Windows命令提示符的更多信息,可以在线获得许多教程

康达 (Conda)

Python comes with a built-in package manager pip, capable of automatically installing Python packages. Many scientific packages, however, have dependencies beyond Python packages. Anaconda comes with its own generic package manager: conda, which can handle complex installation routines containing dependencies and commands unrelated to Python. Unlike pip, it also has the ability to handle environments, replacing the traditional virtualenv. In a conda environment you’ll be able to define exactly which packages and which versions you want to install. You can even change the Python version to use in the environment, in case of legacy packages. By using environments, you greatly reduce the chance of conflicts between your packages and can test various configurations without affecting your global installation.

Python带有内置的软件包管理器pip ,能够自动安装Python软件包。 但是,许多科学软件包都具有Python软件包以外的依赖项。 Anaconda带有自己的通用软件包管理器: conda ,它可以处理包含与Python不相关的依赖项和命令的复杂安装例程。 与pip不同,它还具有处理环境的能力,从而取代了传统的virtualenv。 在conda环境中,您将能够准确定义要安装的软件包和版本。 对于旧版软件包,您甚至可以更改要在环境中使用的Python版本。 通过使用环境,您可以大大减少软件包之间发生冲突的机会,并且可以测试各种配置而不会影响全局安装。

You can get an overview of conda’s command-line options by typing the following command in the Anaconda prompt:

您可以通过在Anaconda提示符下键入以下命令来大致了解conda的命令行选项:

conda --help

conda --help

which is equivalent to:

等效于:

This will give you the following output:

这将为您提供以下输出:

As you can see, the most important functions of conda are managing environments and packages. In the following sections, we’ll tell you how to use these functions in more detail. Note that you can always get more info about the specific command you want to execute by adding the -h flag at the end. This will give you a full overview of the available options, both in their long and short forms.

如您所见, conda最重要的功能是管理环境和程序包。 在以下各节中,我们将告诉您如何更详细地使用这些功能。 请注意,始终可以通过在末尾添加-h标志来获取有关要执行的特定命令的更多信息。 这将为您提供可用选项的完整概述,包括长格式和短格式。

喜欢这篇文章吗? 使用Dataquest学习数据科学! (Enjoying this post? Learn data science with Dataquest!)

  • Learn from the comfort of your browser.
  • Work with real-life data sets.
  • Build a portfolio of projects.
  • 从舒适的浏览器中学习。
  • 处理实际数据集。
  • 建立项目组合。

康达环境 (Conda environments)

Let’s start by creating an environment called demo without any specific packages:

让我们从创建一个没有任何特定软件包的演示环境开始:

When asked to confirm, type y.

当要求确认时,键入y。

If you want to use a specific Python version in the environment you can add it in the command:

如果要在环境中使用特定的Python版本,可以在命令中添加它:

pythonpython =2.7
= 2.7

Which in this case will create an environment using Python 2.7.

在这种情况下,它将使用Python 2.7创建环境。

Similarly, if you already want to add some packages to the environment you can simply add them at the end of the line:

同样,如果您已经想向环境中添加一些软件包,则只​​需在行末添加它们:

The installed packages can be changed later, which we’ll discuss in the next section of this post.

稍后可以更改已安装的软件包,我们将在本文的下一部分中进行讨论。

Once the environment is created, it will show up in the environment list. You can access this list using either:

创建环境后,它将显示在环境列表中。 您可以使用以下任一方式访问此列表:

conda info --envs

conda info --envs

or

要么

Both commands will give you the same output: the name of the environment and the path it is located. Your currently active environment will be marked by an asterisk. By default, this will be the ‘root’ environment, corresponding to your global Anaconda installation.

这两个命令将为您提供相同的输出:环境名称及其所在的路径。 您当前活动的环境将带有星号标记。 默认情况下,这将是“ root”环境,与您的全局Anaconda安装相对应。

As you can see in the figure, we’re still in the root environment. Switching to the new demo environment can be done using the activate command:

如您在图中所看到的,我们仍处于根环境中。 可以使用activate命令切换到新的演示环境:

activate demo

activate demo

Your command-line window will now show the name of the environment at the beginning of the line.

现在,您的命令行窗口将在该行的开头显示环境名称。

Once you’re done, you can leave the environment by typing deactivate.

完成后,您可以通过键入deactivate离开环境。

Now imagine you have fully set up your perfect environment, but you decide to make a change. The safest way to proceed is just to make an exact clone of your current environment. Let’s make an environment called demo2 which will be an exact clone of the demo environment:

现在,假设您已经完全设置了完美的环境,但是您决定进行更改。 最安全的方法是对当前环境进行精确克隆。 让我们创建一个名为demo2的环境,它将是演示环境的精确克隆:

If we decide we don’t need it anymore we can just remove it:

如果我们决定不再需要它,则可以将其删除:

conda remove --name demo2 --all

conda remove --name demo2 --all

You can also make a backup of your environment, either for your own usage or to share with others. To do this, we’ll need to go back into the environment.

您还可以备份环境,以供您自己使用或与他人共享。 为此,我们需要回到环境中。

We can then create an environment file of our current environment:

然后,我们可以创建当前环境的环境文件:

export > demo.yml
export > demo.yml

which can be used to create an identical environment from the file as follows:

可以用来从文件创建相同的环境,如下所示:

This is especially useful on another computer where you cannot clone your environment. Of course, you’ll have to make sure Anaconda Prompt is in the folder that contains your environment file.

这在无法克隆环境的另一台计算机上特别有用。 当然,您必须确保Anaconda Prompt在包含您的环境文件的文件夹中。

管理包 (Managing packages)

Now that we’ve learned how to set up environments, let’s have a look at how to manage the packages within the environments. We already saw you can provide a list of packages to install when the environment is created:

现在,我们已经学习了如何设置环境,让我们看一下如何在环境中管理软件包。 我们已经看到您可以提供创建环境时要安装的软件包的列表:

conda create --name demo scikit-learn statsmodels

conda create --name demo scikit-learn statsmodels

This will install not only the packages themselves, but also all dependencies. Once the environment is created you can view installed packages either using:

这不仅将安装软件包本身,还将安装所有依赖项。 创建环境后,您可以使用以下方法查看已安装的软件包:

Within the environment or, in the case of the demo environment:

在环境中,或者在演示环境中:

conda list --name demo

conda list --name demo

From the main Anaconda prompt.

在主要的Anaconda提示符下。

If you want to install a new package you can first search for it. For example, if we want to look for the babel package:

如果要安装新软件包,可以先进行搜索。 例如,如果我们要查找babel软件包:

This will provide you with a list of packages containing the word babel and the available versions of each.

这将为您提供包含单词babel的软件包列表以及每个软件包的可用版本。

You can then install this package in the demo environment using the install command:

然后,您可以使用install命令在演示环境中安装此软件包:

conda install --name demo babel

conda install --name demo babel

Omitting -n demo will install it in the currently active environment.

省略-n demo会将其安装在当前活动的环境中。

Later you can update the package using the update command:

稍后,您可以使用update命令更新软件包:

You can even update conda itself:

您甚至可以更新conda本身:

conda update conda

conda update conda

If you decide you no longer need a package you can similarly remove it from your environment:

如果您决定不再需要某个软件包,则可以类似地将其从您的环境中删除:

Finally, what do you do if you cannot find the package (or package version) you’re looking for? A first option is to check the additional package channels provided by Anaconda.org. Go to Anaconda.org and use the search box to look for your package. For example, let’s install cartopy. Cartopy is a geographical plotting package being made to replace the deprecated basemap package included with Anaconda. If you search on Anaconda.org you will find it in the conda-forge channel.

最后,如果找不到所需的软件包(或软件包版本),该怎么办? 第一种选择是检查Anaconda.org提供的其他软件包渠道。 转到Anaconda.org并使用搜索框查找您的包裹。 例如,让我们安装cartopy。 Cartopy是一种地理绘图软件包,用于替换Anaconda随附的已弃用的底图软件包。 如果您在Anaconda.org上搜索 ,则会在conda-forge频道中找到它。

It can be installed by running the following command where the -c flag indicates the channel name:

可以通过运行以下命令来安装该命令,其中-c标志指示通道名称:

conda install --name demo --channel conda-forge cartopy

conda install --name demo --channel conda-forge cartopy

It can then be managed like any other package. What if even then you can’t find your package? Well, you can try other package managers such as pip. The latter can actually be installed and used within a conda environment:

然后可以像其他任何软件包一样对其进行管理。 即使仍然找不到包裹怎么办? 好了,您可以尝试使用其他软件包管理器,例如pip 。 后者实际上可以在conda环境中安装和使用:

Then you can use pip as normal within your environment. For example, installing the CPU version of Google’s Deep Learning library Tensorflow will require running the following pip command in your environment:

然后,您可以在您的环境中正常使用pip。 例如,安装Google深度学习库Tensorflow的CPU版本将需要在您的环境中运行以下pip命令:

pip install --ignore-installed --upgrade tensorflow

pip install --ignore-installed --upgrade tensorflow

If neither conda nor pip allows you to add your desired package you will have to check the accompanying documentation for manual installation instructions.

如果condapip不允许您添加所需的软件包,则必须查看随附的文档以获取手动安装说明。

下一步是什么? (What’s next?)

翻译自: https://www.pybloggers.com/2017/11/setting-up-the-pydata-stack-on-windows/

windows查看堆栈信息

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值