在Windows中安装jupyter笔记本 [英] install jupyter notebook in windows

查看:155
本文介绍了在Windows中安装jupyter笔记本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Python版本是3.6.0,我的操作系统是 视窗. 我想使用命令pip install jupyter安装jupyter笔记本. 但是失败了,我得到了以下错误:

解决方案

在Windows中运行Jupyter的三种方法

纯Python"方式

转到python.org,下载并安装最新版本(截至撰写本文时为3.5.1),并确保无论安装在哪里,包含python.exe的目录都在系统PATH环境变量中.我喜欢将其安装在C:驱动器的根目录中C:\Python35,所以我的PATH包含该目录.

安装完成后,您将需要创建一个虚拟环境,一个轻巧,一次性的隔离python安装程序,您可以在其中进行实验并安装第3方库,而不会影响主"安装.为此,请打开Powershell窗口,然后输入以下命令(其中"myenv"是我们要创建的virtualenv的名称,您可以为此使用任何名称):

PS C:\> python -m venv myenv
PS C:\> myenv\Scripts\activate

然后,让我们安装jupyter并启动笔记本:

PS C:\> pip install jupyter
PS C:\> jupyter notebook

偶然地,如果您收到有关升级pip的警告,请确保使用以下命令进行升级(以防止pip无法就地升级其自己的可执行文件的Windows出现问题):

PS C:\> python -m pip install --upgrade pip

优点:使用纯" python,官方工具,并且没有外部依赖项.良好的支持,拥有大量的在线文档和支持社区.

缺点:虽然可以通过pip在Windows上安装许多流行的数据分析或科学python库(包括Pandas和Matplotlib),但有些(例如SciPy)需要C编译器,并且系统上存在第三方C库.在Windows上很难安装.

它是给谁的? Python用户对Python本身附带的命令行和工具感到满意.

Python发行版

由于上面提到的在Windows上安装SciPy之类的软件包时遇到的困难,一些商业实体将预先打包的Python发行版"放在一起,这些发行版包含(如果不是全部的话)大多数用于数据分析和/的大多数常用库.或科学计算.

Anaconda是一个很好的选择.下载其适用于Windows的Python 3.5安装程序,运行它,然后在开始"菜单中将有许多简洁的新工具,包括Jupyter Notebook的条目.单击以启动它,它将在后台启动,并打开浏览器到笔记本电脑控制台.没有比这更容易的事了.

优势:最简单,最快的入门方式,它可能附带了您的科学计算项目所需的一切.它附带的任何内容仍然可以通过其内置的conda软件包管理器进行安装.

缺点:尽管conda软件包管理器提供了与conda create命令非常相似的功能,但没有virtualenv支持.依靠商业第三方的支持.

它是给谁的?想要最快,最简单的方法来启动并运行Jupyter笔记本的人(IE,大多数人).

Docker

Docker是一个平台,用于在"containers"或独立的独立进程中运行软件.尽管听起来在概念上与python虚拟环境相似,但是Docker容器是一种完全不同的技术,具有极大的灵活性和功能.不过,不要让灵活性,功能和令人困惑的术语让您失望-Docker可以轻松在您的PC上启动和运行,并且相对于Python和Jupyter具有其自身的一些优势.

要在Windows上开始使用,请下载Docker Toolbox,其中包含启动和运行所需的工具.如果尚未安装Virtualbox或其他虚拟化平台(like VMWare Workstation),请运行安装程序并确保选中了Virtualbox复选框.

安装后,开始"菜单中将出现"Docker Quickstart Terminal"快捷方式.双击该快捷方式,它将为您创建第一个Docker引擎并自动设置您需要的所有内容.一旦在终端上看到提示,就可以使用docker run命令运行Docker映像",您可以将其视为预打包的软件捆绑包,在运行它们时会自动从Docker Hub下载. Docker Hub上有很多提供Jupyter的映像,包括官方的Jupyter Notebook映像,如果您需要完整的SciPy堆栈,则可以使用Anaconda本身.

要仅在Docker引擎中运行正式的Jupyter Notebook映像,请在Docker Quickstart Terminal中键入以下内容:

$ docker run --rm -it -p 8888:8888 -v "$(pwd):/notebooks" jupyter/notebook

下载所有图像的图层"后,它将启动.记下终端中列出的IP地址(例如192.168.99.100),然后将浏览器指向该IP地址port 8888(例如http://192.168.99.100:8888),您将看到熟悉的Jupyter console,其中Python 2Python 3内核均可用.

优势:使用Docker的灵活性和强大功能!老实说,关于Docker,我最喜欢的事情之一就是将其视为一个开放的软件分发平台,用于诸如SciPy堆栈之类难以安装的东西.

缺点:应对Docker的灵活性和强大功能!在处理Docker时,有很多陷阱"要注意,例如不可变的容器,数据量,不可思议的命令以及快速开发的,有时是错误的工具.

My Python version is 3.6.0 and my operating system is Windows. I want to install jupyter notebook using the order pip install jupyter. But it failed, I got the following error:

解决方案

Three Ways to Run Jupyter In Windows

The "Pure Python" Way

Make your way over to python.org, download and install the latest version (3.5.1 as of this writing) and make sure that wherever you install it, the directory containing python.exe is in your system PATH environment variable. I like to install it in the root of my C: drive, e.g. C:\Python35, so my PATH contains that directory.

Once that's installed, you'll want to create a virtual environment, a lightweight, disposable, isolated python installation where you can experiment and install 3rd party libraries without affecting your "main" installation. To do this, open up a Powershell window, and enter the following commands (where "myenv" is the name of the virtualenv we're going to create, you can use any name you like for this):

PS C:\> python -m venv myenv
PS C:\> myenv\Scripts\activate

Then, let's install jupyter and start up a notebook:

PS C:\> pip install jupyter
PS C:\> jupyter notebook

Incidentally, if you get a warning about upgrading pip, make sure to use the following incantation to upgrade (to prevent an issue on windows where pip is unable to upgrade its own executable in-place):

PS C:\> python -m pip install --upgrade pip

Advantages: Uses "pure" python, official tools, and no external dependencies. Well supported, with plenty of online documentation and support communities.

Disadvantages: While many popular data analysis or scientific python libraries can be installed by pip on windows (including Pandas and Matplotlib), some (for example SciPy) require a C compiler and the presence of 3rd party C libraries on the system which are difficult to install on Windows.

Who is it for? Python users comfortable with the command line and the tools that ship with Python itself.

The Python Distributions

Because of the difficulty mentioned above in getting packages like SciPy installed on Windows, a few commercial entities have put together pre-packaged Python "distributions" that contain most, if not all, of the commonly used libraries for data analysis and/or scientific computing.

Anaconda is an excellent option for this. Download their Python 3.5 installer for Windows, run it, and in your Start menu you'll have a bunch of neat new tools, including an entry for Jupyter Notebook. Click to start it up and it'll launch in the background and open up your browser to the notebook console. It doesn't get any easier than that.

Advantages: Simplest, fastest way to get started and it comes with probably everything you need for your scientific computing projects. And anything it doesn't ship with you can still instalAl via its built in conda package manager.

Disadvantages: No virtualenv support, although the conda package manager provides very similar functionality with the conda create command. Relies on a commercial 3rd party for support.

Who is it for? People who want the quickest, easiest way to get Jupyter notebook up and running (IE, most people).

Docker

Docker is a platform for running software in "containers", or self-contained, isolated processes. While it may sound similar in concept to python virtual environments, Docker containers are an entirely different kind of technology offering vast flexibility and power. Don't let the flexibility and power and confusing terminology put you off though -- Docker can be easy to get up and running on your PC and has some advantages of its own with respect to Python and Jupyter.

To get started on Windows, download the Docker Toolbox, which contains the tools you need to get up and running. Run the installer and make sure the checkbox to install Virtualbox is checked if you don't already have Virtualbox or another virtualization platform (like VMWare Workstation) installed.

Once installed, you'll have a "Docker Quickstart Terminal" shortcut in your Start Menu. Double click that shortcut and it will create your first Docker engine for you and set up everything you need automatically. Once you see a prompt in the terminal, you can use the docker run command to run Docker "images", which you can think of as pre-packaged bundles of software that will be automatically downloaded from the Docker Hub when you run them. There are many images on Docker Hub that offer Jupyter, including the official Jupyter Notebook image, and Anaconda itself if you want the full SciPy stack.

To run just the official Jupyter Notebook image in your Docker engine, type the following into the Docker Quickstart Terminal:

$ docker run --rm -it -p 8888:8888 -v "$(pwd):/notebooks" jupyter/notebook

After all the image's "layers" are downloaded, it will start up. Make a note of the IP address listed in the terminal (for example, 192.168.99.100), and point your browser at that IP address, port 8888 (e.g. http://192.168.99.100:8888) and you'll see the familiar Jupyter console, with both Python 2 and Python 3 kernels available.

Advantages: Use the flexibility and power of Docker! Honestly one of my favorite things about Docker is thinking of it as an open software distribution platform for things like the SciPy stack that are hard to install.

Disadvantages: Grapple with the flexibility and power of Docker! There are quite a few "gotchas" to be aware of when dealing with Docker, such as immutable containers, data volumes, arcane commands, and rapidly developing, occasionally buggy tooling.

这篇关于在Windows中安装jupyter笔记本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆