简体   繁体   English

在 Windows 上通过命令行运行 Jupyter

[英]Running Jupyter via command line on Windows

I have installed Jupyter on Windows 10, Python 3.x via我已经通过在 Windows 10、Python 3.x 上安装了 Jupyter

$ pip install jupyter

The installation works fine, even though I did restart the terminal.安装工作正常,即使我确实重新启动了终端。

But trying to run但试图运行

$ jupyter notebook

gives the following error给出以下错误

'jupyter' is not recognized as an internal or external command, operable program or batch file.

How and where do I find the executable for Jupyter?如何以及在哪里找到 Jupyter 的可执行文件?

If you are absolutely sure that your Python library path is in your system variables (and you can find that path when you pip install Jupyter, you just have to read a bit) and you still experience "command not found or recognized" errors in Windows, you can try:如果您绝对确定您的 Python 库路径在您的系统变量中(并且您可以在 pip install Jupyter 时找到该路径,您只需阅读一下)并且您仍然会在 Windows 中遇到“找不到或无法识别命令”错误, 你可以试试:

python -m notebook

For my Windows at least (Windows 10 Pro), having the python -m is the only way I can run my Python packages from command line without running into some sort of error至少对于我的 Windows(Windows 10 Pro),拥有python -m是我可以从命令行运行 Python 包而不会遇到某种错误的唯一方法

Fatal error in launcher: Unable to create process using ' "

or或者

Errno 'THIS_PROGRAM' not found

Please try either of these commands first;请先尝试以下任一命令;

$ py -m notebook
$ python -m notebook

for jupyterlab users对于 jupyterlab 用户

py -m jupyterlab

Otherwise否则

$ python -m pip install jupyter --user
$ jupyter notebook

If this does not work.如果这不起作用。

pip does not add jupyter directly to path for local. pip 不会将 jupyter 直接添加到本地路径。

The output from从输出

$ which python
/c/Users/<username>/AppData/Local/Programs/Python/Python35-32/python

After some digging I found a executable for jupyter in the folder:经过一番挖掘,我在文件夹中找到了 jupyter 的可执行文件:

C:\Users\<username>\AppData\Roaming\Python\Python35\Scripts\jupyter.exe

Difference between local and roaming folder 本地文件夹和漫游文件夹的区别

So if you want to be able to execute a program via command line, you need to add it into the %PATH variable.因此,如果您希望能够通过命令行执行程序,则需要将其添加到 %PATH 变量中。 Here is a powershell script to do it.这是执行此操作的 powershell 脚本。 BE SURE TO ADD THE ";"请务必添加“;” before adding the new path.在添加新路径之前。

$ [Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Users\<username>\AppData\Roaming\Python\Python35\Scripts", [EnvironmentVariableTarget]::User)

Update:更新:

if you are using python3 , switch out python with python3 but I encourage you to use pyenv instead :)如果您使用的是python3 ,请使用python3切换python ,但我鼓励您改用pyenv :)

I had the same problem, but我有同样的问题,但是

py -m notebook

worked for me.为我工作。

I had the exact same problem and it was driving me crazy.我遇到了完全相同的问题,这让我发疯了。 Other answers provide a solution, but they don't explain why you and I are having this problem.其他答案提供了解决方案,但他们没有解释为什么你和我会遇到这个问题。

I will try to explain why this is happening and then provide some solutions.我将尝试解释为什么会发生这种情况,然后提供一些解决方案。

You can go to the end to see the TL;DR.你可以到最后看看 TL;DR。

1)What's going on? 1)发生了什么事? Why is this error happening?为什么会发生此错误?

I'll try to make a step-by-step answer so everything is explained clearly.我将尝试逐步回答,以便清楚地解释所有内容。 If you think it's too basic at the beginning, go to the end of this "article".如果一开始觉得太基础,就到本“文章”的最后。

I'll first start with common things like running the python shell from the terminal or running pip .我将首先从常见的事情开始,例如从终端运行python shell 或运行pip You'll see why you can do that from the terminal and we'll end up on why and how you can run the jupyter notebook from the terminal as well.您将了解为什么可以从终端执行此操作,我们将最终说明为什么以及如何从终端运行jupyter notebook。

Ready?准备好? Let's start!开始吧!


Have you ever wondered why you can type python in the terminal (command prompt) and suddenly start the Python interpreter?你有没有想过为什么你可以在终端(命令提示符)中输入python并突然启动 Python 解释器?

Microsoft Windows [Version 10.0.18363.1440]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\YOUR-USERNAME>python
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

You probably already know (but maybe don't) that this is because Python was added to the Windows PATH environment variable.您可能已经知道(但可能不知道)这是因为 Python 已添加到 Windows PATH环境变量中。 You probably did it at installation time or afterwards .您可能是在安装时或之后进行的。

But, what is this PATH environment variable?但是,这个PATH环境变量是什么?

It basically allows you to run any executables, that are located inside the paths specified in the variable, at the command prompt without having to give the full path to the executable.它基本上允许您在命令提示符下运行位于变量中指定的路径内的任何可执行文件,而无需提供可执行文件的完整路径。

You can check the content of that PATH variable with:您可以使用以下命令检查该PATH变量的内容:

>>> import sys
>>> for path in sys.path:
        print(path)

C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\python39.zip
C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\DLLs
C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\lib
C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39
C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\lib\site-packages
... (some other paths were taken out for clarity)

You can see this folder: C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39 .您可以看到此文件夹: C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39 This is the place where Python version 3.9 is installed.这是安装 Python 3.9 的地方。 Let's check its content:让我们检查一下它的内容:

<DIR>   DLLs
<DIR>   Doc
<DIR>   etc
<DIR>   include
<DIR>   Lib
<DIR>   libs
<DIR>   Scripts
<DIR>   share
<DIR>   tcl
<DIR>   Tools
        LICENSE.txt
        NEWS.txt
        python.exe
        python3.dll
        python39.dll
        pythonw.exe
        vcruntime140.dll
        vcruntime140_1.dll

Voilà!瞧! We have the python.exe file (an executable ).我们有python.exe文件(一个可执行文件)。 We have a Python executable file in the PATH , that's why you can start the Python interpreter from the terminal with just typing python .我们在PATH中有一个 Python 可执行文件,这就是为什么您只需键入python即可从终端启动 Python 解释器的原因。 If this wasn't the case you would have to type the full path to the executable file in the terminal:如果不是这种情况,您必须在终端中键入可执行文件的完整路径:

C:\Users\YOUR-USERNAME> C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\python)

Instead of just:而不仅仅是:

C:\Users\YOUR-USERNAME> python

And what about when you use pip ?当你使用pip时呢?

It's the same principle.这是相同的原理。 You can run pip from the terminal because there is a pip executable file in the PATH variable.您可以从终端运行pip ,因为PATH变量中有一个pip可执行文件。

If you go to C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\Scripts\ (which is in the PATH showed above) you'll see many executables files.如果您转到C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\Scripts\ (位于上面显示的PATH中),您将看到许多可执行文件。 One of them is pip .其中之一是pip Actually I have three versions: pip , pip3.9 and pip3 .实际上我有三个版本: pippip3.9pip3

The Scripts folder allows exectuable files to be run from the terminal. Scripts 文件夹允许从终端运行可执行文件。 Like pip or other libraries that you intend to run directly from the terminal.就像您打算直接从终端运行的pip或其他库一样。 The Scripts folder: Scripts文件夹:

...is not intended for you, it's for scripts that are installed as components of modules that you install. ...不适合您,它适用于作为您安装的模块组件安装的脚本。 For example, pip is a module, but it also has a wrapper script by the same name, pip, which will be installed in that directory.例如,pip 是一个模块,但它也有一个同名的包装脚本 pip,它将安装在该目录中。

If you put something there and it is properly in your PATH, then it should be executable如果你把东西放在那里并且它在你的 PATH 中正确,那么它应该是可执行的

That wrapper script would be the pip executable file.该包装脚本将是pip可执行文件。 When this executable file is run, it locates the pip folder in the Python installation folder and runs pip .运行此可执行文件时,它会在 Python 安装文件夹中找到pip文件夹并运行pip

But you could also run pip directly from the installation folder ( C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\Lib\site-packages ), without needing the executable pip file.但是您也可以直接从安装文件夹( C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\Lib\site-packages )运行pip ,而不需要可执行的pip文件。

But, how can you do it?但是,你怎么能做到呢?

I'm glad you ask.我很高兴你问。 There is a Python way to run modules as the main module (without the need to import it).有一种 Python方法可以将模块作为主模块运行(无需导入它)。

python -m pip

When you run a module directly its name becomes __main__ .当你直接运行一个模块时,它的名字变成了__main__ What -m does is: -m的作用是:

Search sys.path for the named module and execute its contents as the __main__module .sys.path中搜索命名模块并将其内容作为__main__模块执行。

What is __main__ ?什么是__main__

'__main__' is the name of the scope in which top-level code executes. '__main__'是顶级代码执行的范围的名称。

A module's __name__ is set equal to '__main__' when read from standard input, a script, or from an interactive prompt.当从标准输入、脚本或交互式提示中读取时,模块的__name__设置为等于'__main__' ... ...

I guess that the pip executable does something similar, or at least, has the same effect: to start pip .我猜pip可执行文件做了类似的事情,或者至少具有相同的效果:启动pip


2)What does this have to do with the Jupyter Notebook?! 2)这与 Jupyter Notebook 有什么关系?!

Think of the Jupyter Notebook as the same as pip .Jupyter Notebook想象成与pip相同。 If you want to run jupyter in the terminal, you need an executable that it's on the PATH .如果要在终端中运行jupyter ,则需要一个位于PATH上的可执行文件。

We have already seen that the executables of modules like pip or jupyter are located here C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\Scripts\ .我们已经看到pipjupyter等模块的可执行文件位于C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\Scripts\

If I check the content of the folder I see this:如果我检查文件夹的内容,我会看到:

easy_install-3.9.exe
easy_install.exe
f2py.exe
jsonschema.exe
jupyter-bundlerextension.exe
jupyter-console.exe
jupyter-nbconvert.exe
jupyter-nbextension.exe
jupyter-notebook.exe
jupyter-qtconsole.exe
jupyter-serverextension.exe
jupyter-trust.exe
pip.exe
pip3.9.exe
pip3.exe

I see the already mentioned pip , pip3.9 and pip3 .我看到已经提到的pippip3.9pip3 But I don't see jupyter (the word " jupyter " alone).但我没有看到jupyter (单独的“ jupyter ”这个词)。

If I type jupyter in the terminal I get the error that started all:如果我在终端中键入jupyter ,我会收到启动所有错误的错误:

'jupyter' is not recognized as an internal or external command, operable program or batch file.

Finally we've reached an answer to your question!!!终于找到你的问题的答案了!!!


'jupyter' is not recognized as a command because there is no executable file in the Scripts folder called jupyter . 'jupyter' 未被识别为命令,因为Scripts文件夹中没有名为jupyter的可执行文件。


So, let's try a different executable.所以,让我们尝试一个不同的可执行文件。 What about jupyter-notebook ? jupyter-notebook呢?

BINGO!答对了! The notebook is running!笔记本正在运行!

Serving notebooks from local directory:
C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\Scripts
Jupyter Notebook 6.3.0 is running at:
http://localhost:8888/?token=... (edited)
or http://127.0.0.1:8888/?token=... (edited)
Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

I don't know why I don't have a jupyter executable called 'jupyter'.我不知道为什么我没有名为“jupyter”的jupyter可执行文件。 The official documentation says to use jupyter notebook on the terminal, but it seems that in some cases it doesn't work.官方文档说要在终端上使用jupyter notebook ,但似乎在某些情况下它不起作用。 And I think it has to do with what I mentioned above: there is no jupyter exectuable in the Scripts folder.而且我认为这与我上面提到的有关: Scripts文件夹中没有jupyter文件。


If you remember, I told you that you can run pip as the main module using python -m pip .如果您还记得,我告诉过您可以使用python -m pippip作为主模块运行。

It happens that you can do the same with jupyter .We just need to know how to call it.碰巧你可以用jupyter做同样的事情。我们只需要知道如何调用它。 As in with pip , we have to check the folder where 3rd party libraries are installed: C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\Lib\site-packages .pip一样,我们必须检查安装第 3 方库的文件夹: C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\Lib\site-packages

You'll see jupyter_console , but this just creates an interactive notebook in the terminal, not exactly what you were looking for.您会看到jupyter_console ,但这只是在终端中创建了一个交互式笔记本,而不是您想要的。 You're also going to find folders ending with .dist.info , like jupyter_console-6.4.0.dist-info .您还将找到以.dist.info结尾的文件夹,例如jupyter_console-6.4.0.dist-info This is just metadata of the Wheel Binary Package builder.这只是 Wheel Binary Package 构建器的元数据 You'll also see a folder like jupyterlab_pygments , but that's for JupyterLab .您还会看到一个类似jupyterlab_pygments的文件夹,但这针对JupyterLab的。 We want to use the classic Jupyter notebook.我们想使用经典的 Jupyter notebook。

What we want is to run notebook .我们想要的是运行notebook How do we know this?我们怎么知道呢?

You'll see in the folder site-packages the folder ( package ) notebook .您将在文件夹site-packages中看到文件夹 ( package ) notebook Inside there is a file called __main__.py :里面有一个名为__main__.py的文件:

#__main__.py
if __name__ == '__main__':
    from notebook import notebookapp as app
    app.launch_new_instance()

It's calling notebookapp.py which is a "A tornado based Jupyter notebook server."它调用notebookapp.py ,它是一个“基于龙卷风的 Jupyter 笔记本服务器”。 Yes, this is what we need.是的,这就是我们需要的。

We can see that launch_new_instance in the notebookapp calls launch_instance() , which " launches an instance of a Jupyter Application ".我们可以看到notebookapp中的launch_new_instance调用了launch_instance()启动了一个 Jupyter 应用程序的实例”。

Perfect!完美的! We are in the correct folder.我们在正确的文件夹中。 To run the jupyter notebook from the Python interactive shell we have to run the notebook package with:要从 Python 交互式 shell 运行 jupyter notebook,我们必须运行 notebook 包:

python -m notebook

3)*** SUMMARY: SOLUTION *** 3)*** 总结:解决方案 ***

tl;dr: tl;博士:

I have explained and showed why this error is happening.我已经解释并说明了为什么会发生这个错误。

Now let's summarize the solutions:现在让我们总结一下解决方案:

  1. To know the name of the jupyter executable (in the Scripts folder), so you can run directly from the terminal (Command Prompt) as:要知道jupyter可执行文件的名称(在Scripts文件夹中),因此您可以直接从终端(命令提示符)运行:

     jupyter notebook

or as:或作为:

    jupyter-notebook

Or whatever name you have.或者你有什么名字。

  1. Run the notebook as the main module from Python:从 Python 将 notebook 作为主模块运行:

     python -m notebook

I hope this helps you as much as it helped me.我希望这对你有帮助,就像它对我有帮助一样。 I'm open to your comments and suggestions.我愿意接受您的意见和建议。

I got Jupyter notebook running in Windows 10. I found the easiest way to accomplish this task without relying upon a distro like Anaconda was to use Cygwin.我让 Jupyter notebook 在 Windows 10 中运行。我发现在不依赖像 Anaconda 这样的发行版的情况下完成这项任务的最简单方法是使用 Cygwin。

In Cygwin install python2, python2-devel, python2-numpy, python2-pip, tcl, tcl-devel, (I have included a image below of all packages I installed) and any other python packages you want that are available.在 Cygwin 中安装 python2、python2-devel、python2-numpy、python2-pip、tcl、tcl-devel(我在下面包含了我安装的所有软件包的图像)以及您想要的任何其他可用的 python 软件包。 This is by far the easiest option.这是迄今为止最简单的选择。

Then run this command to just install jupyter notebook:然后运行这个命令来安装 jupyter notebook:

python -m pip install jupyter

Below is the actual commands I ran to add more libraries just in case others need this list too:以下是我为添加更多库而运行的实际命令,以防其他人也需要此列表:

python -m pip install scipy

python -m pip install scikit-learn

python -m pip install sklearn

python -m pip install pandas

python -m pip install matplotlib

python -m pip install jupyter

If any of the above commands fail do not worry the solution is pretty simple most of the time.如果上述任何命令失败,请不要担心解决方案在大多数情况下都非常简单。 What you do is look at the build failure for whatever missing package / library.您所做的是查看任何缺少的包/库的构建失败。

Say it is showing a missing pyzmq then close Cygwin, re-open the installer, get to the package list screen, show "full" for all, then search for the name like zmq and install those libraries and re-try the above commands.假设它显示缺少 pyzmq,然后关闭 Cygwin,重新打开安装程序,进入包列表屏幕,显示全部“完整”,然后搜索 zmq 之类的名称并安装这些库并重试上述命令。

Using this approach it was fairly simple to eventually work through all the missing dependencies successfully.使用这种方法,最终成功处理所有缺失的依赖项是相当简单的。

Cygwin package list Cygwin 软件包列表

Once everything is installed then run in Cygwin goto the folder you want to be the "root" for the notebook ui tree and type:安装完所有内容后,在 Cygwin 中运行,转到要成为笔记本 ui 树的“根”的文件夹,然后键入:

jupyter notebook

This will start up the notebook and show some output like below:这将启动笔记本并显示如下输出:

$ jupyter notebook
[I 19:05:30.459 NotebookApp] Serving notebooks from local directory: 
[I 19:05:30.459 NotebookApp] 0 active kernels
[I 19:05:30.459 NotebookApp] The Jupyter Notebook is running at: 
[I 19:05:30.459 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

Copy/paste this URL into your browser when you connect for the first time, to login with a token:

http://localhost:8888/?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

You can add the following to your path您可以将以下内容添加到您的路径

C:\[Python Installation path]\Scripts

eg C:\Python27\Scripts例如C:\Python27\Scripts

It will start working for jupyter and every other pip install you will do here on.它将开始为 jupyter 和您将在此处执行的所有其他 pip 安装工作。

In Python 3.7.6 for Windows 10. After installation, I use these commands.在适用于 Windows 10 的Python 3.7.6中。安装后,我使用这些命令。

1. pip install notebook
2. python -m notebook

OR或者

C:\Users\Hamza\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\Scripts . C:\Users\Hamza\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\Scripts 。

For my pc python-scripts are located in the above path.对于我的电脑,python 脚本位于上述路径中。 You can add this path in environment variables.您可以在环境变量中添加此路径。 Then run command.然后运行命令。

1. jupyter notebook

如果您使用的是 Anaconda 发行版,请确保在安装时选中“更改路径”选项。

Check whether you have given python PATH in environmental variables properly.检查您是否在环境变量中正确给出了 python PATH。
If not, then set python path.如果没有,则设置 python 路径。 Then use:然后使用:

$ python -m notebook

I added我添加了

 c:\users\[user]\appdata\roaming\python\python37\site-packages

to the path and it worked.到路径,它起作用了。

In Windows 10 you can use ipython notebook .在 Windows 10 中,您可以使用ipython notebook It works for me.这个对我有用。

Here is how I resolved stated issue, hope it helps:以下是我解决上述问题的方法,希望对您有所帮助:

  1. install python 3.7 using official website for python, while installing include installing PATH by checking it's box使用python官方网站安装python 3.7,同时安装包括通过选中它的框来安装PATH

  2. after that open cmd (be sure to open it after step 1) and write: pip install jupyter ENTER之后打开 cmd(确保在步骤 1 之后打开它)并写入:pip install jupyter ENTER

  3. now you should be able to open jupyter notebook by using command: jupyter notebook现在您应该可以使用以下命令打开 jupyter notebook:jupyter notebook

Seems simple, but it may as well help.看起来很简单,但它也可能有所帮助。

first you should make sure that you are put your python path in your system variables .. Then try run this首先你应该确保你把你的python路径放在你的系统变量中..然后尝试运行这个

python -m pip install jupyter --user

and then run this然后运行这个

py -m notebook or  jupyter notebook

Problem for me was that I was running the jupyter command from the wrong directory.对我来说问题是我从错误的目录运行jupyter命令。

Once I navigated to the path containing the script, everything worked.一旦我导航到包含脚本的路径,一切正常。

Path- C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\Scripts路径 - C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\Scripts

## windows CMD ## 窗口命令

for default install (just check "add path" and "next" when installing)默认安装(安装时只需检查“添加路径”和“下一步”)

jupyter notebook

for custom install in C:\用于 C:\ 中的自定义安装

jupyter notebook

I have two python version installed: 1. Python 3.8.2: This was installed independently 2. Python 3.7.6: This was installed along with Anaconda 3我安装了两个 python 版本: 1. Python 3.8.2:这是独立安装的 2. Python 3.7.6:这是与 Anaconda 3 一起安装的

Multiple versions caused conflict even after setting the path variables correctly.即使正确设置了路径变量,多个版本也会导致冲突。

I have uninstalled the Python 3.8.2 and after restart, the command我已经卸载了 Python 3.8.2,重启后,命令

jupyter notebook

Worked perfectly :)工作完美:)

you can create a batch file and search for Jupiter in your windows search and ooen its properties and you will get this string.您可以创建一个批处理文件并在 Windows 搜索中搜索 Jupiter 并打开其属性,您将获得此字符串。 D:\anaconda3\python.exe D:\anaconda3\cwp.py D:\anaconda3 D:\anaconda3\python.exe D:\anaconda3\Scripts\jupyter-notebook-script.py "%USERPROFILE%/" after getting this you can create a jupitor.bat file with this content it that and you can save that file in a script folder in d or any drive and add the path of your script file in your environmental path D:\anaconda3\python.exe D:\anaconda3\cwp.py D:\anaconda3 D:\anaconda3\python.exe D:\anaconda3\Scripts\jupyter-notebook-script.py "%USERPROFILE%/"获取后这您可以创建一个包含此内容的 jupitor.bat 文件,您可以将该文件保存在 d 或任何驱动器的脚本文件夹中,并将脚本文件的路径添加到环境路径中

and then you can easly call this by typing jupitor in cmd.然后你可以通过在 cmd 中输入 jupitor 来轻松调用它。

To install I used "pip install notebook" in windows command line要安装,我在 Windows 命令行中使用了“pip install notebook”

To run python -m notebook did not work for me, but python3 -m notebook worked运行 python -m notebook 对我不起作用,但 python3 -m notebook 有效

First run this command首先运行这个命令

pip install jupyter点安装 jupyter

then add system variable path , this path is where jupyter and other scripts are located然后添加系统变量路径,这个路径就是jupyter等脚本所在的位置

PATH = C:\Users<userName>\AppData\Roaming\Python\Python38\Scripts PATH = C:\Users<用户名>\AppData\Roaming\Python\Python38\Scripts

eg PATH=C:\Users\HP\AppData\Roaming\Python\Python38\Scripts例如 PATH=C:\Users\HP\AppData\Roaming\Python\Python38\Scripts

After that we can run jupyter from any folder/directory之后,我们可以从任何文件夹/目录运行 jupyter

jupyter notebook jupyter笔记本

I just found that error when I first intalled and run the jupyter notebook.我刚安装并运行 jupyter notebook 时发现了这个错误。 Then I found the executable (.exe) file from C:\Users\<user-name>\AppData\Local\Programs\Python\Python39\Scripts .然后我从C:\Users\<user-name>\AppData\Local\Programs\Python\Python39\Scripts找到了可执行(.exe)文件。 The actual file name was "jupyter-notebook" .实际文件名是"jupyter-notebook" The installation guide says it as "jupyter notebook" to run the server.安装指南将其称为"jupyter notebook"来运行服务器。 You have to run the command "jupyter-notebook" in the command line and it will be run.您必须在命令行中运行命令"jupyter-notebook" ,它将运行。 Thanks!谢谢!

My problem was my user's folder had a space in folder name.我的问题是我用户的文件夹在文件夹名称中有一个空格。

After creating a new user and switching to that windows user, windows shortcuts and links from within' Anaconda worked fine.创建新用户并切换到该 Windows 用户后,来自 Anaconda 的 Windows 快捷方式和链接工作正常。

Windows 8.1 64 Bit. Windows 8.1 64 位。 Latest Anaconda.最新的蟒蛇。

Note: I ended up uninstalling an reinstalling Anaconda but my sense is the problem was really just the space in the windows user username/user folder.注意:我最终卸载了重新安装的 Anaconda,但我的感觉是问题实际上只是 Windows 用户用户名/用户文件夹中的空间。

Using python 3.6.3.使用 python 3.6.3。 Here after installing Jupyter through command ' python -m pip install jupyter ', ' jupyter notebook ' command didn't work for me using windows command prompt.在通过命令“ python -m pip install jupyter ”安装 Jupyter 之后,使用 Windows 命令提示符时,“ jupyter notebook ”命令对我不起作用。

But, finally ' python -m notebook ' did work and made jupyter notebook to run on local.但是,最后' python -m notebook '确实起作用并使jupyter notebook在本地运行。

http://localhost:8888/tree http://localhost:8888/tree

In windows 10: If you used anaconda3 for Jupyter notebook installation and forgot to check the box to add the environment variables to the system during installation, you need to add the following environment variables to the "Path" variable manually: (search windows settings for Edit environment variables")在windows 10中:如果你使用anaconda3安装Jupyter notebook,安装时忘记勾选将环境变量添加到系统,需要手动将以下环境变量添加到“Path”变量中:(搜索windows settings for编辑环境变量”)

Environment variables for Anaconda3 Anaconda3 的环境变量

If you have installed jupyter with "python -m pip install jupyter" command instead of "$ pip install jupyter" command then follow these steps:如果您使用“python -m pip install jupyter”命令而不是“$ pip install jupyter”命令安装了 jupyter,请按照以下步骤操作:

  1. Create a notepad创建记事本
  2. Change its extension from ".txt" to ".ipynb"将其扩展名从“.txt”更改为“.ipynb”
  3. Right click it and click "open with"右键单击它,然后单击“打开方式”
  4. In the pop up, go to - C:\Users\<"windows_user_name">\AppData\Roaming\Python\Python38\Scripts在弹出窗口中,转到 - C:\Users\<"windows_user_name">\AppData\Roaming\Python\Python38\Scripts
  5. Click on "jupyter-lab.exe"点击“jupyter-lab.exe”

100% working solution: 100% 工作解决方案:

Follow these steps:按着这些次序:

  1. Open the folder where you downloaded "python-3.8.2-amd64.exe" setup or any other version of python package打开下载“python-3.8.2-amd64.exe”安装程序或任何其他版本的python包的文件夹

  2. Double click on "python-3.8.2-amd64.exe'双击“python-3.8.2-amd64.exe”

  3. Click "Modify"点击“修改”

  4. You will see "Optional features"您将看到“可选功能”

  5. Click "next"点击下一步”

  6. Select "Add python to environment variables"选择“将python添加到环境变量”

  7. Click "install"点击“安装”

  8. Then u can run jupyter in any desired folder u desire然后你可以在你想要的任何文件夹中运行 jupyter

    E.g  open "cmd" command prompt

    Type : 
    E: 

    E:\>jupyter notebook

    It will get started without showing

    'Jupyter' is not recognized

Thanks谢谢

I was facing the same issue in windows7, as i just recoverd my computer with the help of recovery point and after that notebook just stopped working.我在windows7中遇到了同样的问题,因为我刚刚在恢复点的帮助下恢复了我的电脑,之后那个笔记本就停止了工作。 I tried to change the path setting but nothing was working so I just simply uninstalled the python with the application from which it was installed and after that I installed it again.我试图更改路径设置,但没有任何效果,所以我只是简单地使用安装它的应用程序卸载了 python,然后我再次安装它。 After that I installed jupyter notebook again and then it worked fine.之后,我再次安装了 jupyter notebook,然后它运行良好。 Thanks谢谢

I just installed JupyterLab on top of my Python 3.8/pip enabled Win10 machine, so I ran into these startup problem with windows.我刚刚在启用 Python 3.8/pip 的 Win10 机器上安装了 JupyterLab,所以我遇到了这些 Windows 启动问题。 If everything is ok (check that you have PATH for Python, eg. C:\Users[Username]\AppData\Local\Programs\Python\Python38-32\Scripts) you simply run:如果一切正常(检查您是否有 Python 的 PATH,例如 C:\Users[Username]\AppData\Local\Programs\Python\Python38-32\Scripts),您只需运行:

jupyter-lab.exe jupyter-lab.exe

and that's it.就是这样。

Cheers干杯

Add system variable path, this path is where jupyter and other scripts are located添加系统变量路径,这个路径是jupyter等脚本所在的位置

PATH -->路径 -->

`C:\Users\<userName>\AppData\Roaming\Python\Python39\Scripts`

Like in my laptop PATH is:就像在我的笔记本电脑中一样,PATH 是:

"C:\Users\developer\AppData\Roaming\Python\Python39\Scripts"

After that, You will be able to run jupyter from any folder & any directory by running the below command之后,您将能够通过运行以下命令从任何文件夹和任何目录运行 jupyter

jupyter notebook jupyter笔记本

Had the same issue.有同样的问题。 Finally searched where jupyter.exe directory was located on my computer.最后搜索到了 jupyter.exe 目录在我电脑上的位置。 For some reason it was under C:\VTRoot\HarddiskVolume4\Users[user]\AppData\Local\Programs\Python由于某种原因,它位于 C:\VTRoot\HarddiskVolume4\Users[user]\AppData\Local\Programs\Python 下

Whereas the Python is C:\Users[user]\AppData\Local\Programs\Python而 Python 是 C:\Users[user]\AppData\Local\Programs\Python

So I copied full Python39 folder from VTRoot to main Python39 python folder in AppData.所以我将完整的 Python39 文件夹从 VTRoot 复制到 AppData 中的主要 Python39 python 文件夹。 And the issue is solved.问题就解决了。

First check where your python is installed by heading over to首先检查你的python的安装位置,前往

C:\Users\**username**\AppData\Local\Programs\Python\Python39\Scripts

this is the path usually you will find python installed.这是通常您会发现安装了 python 的路径。 After this type in在这个输入之后

cd..  to get one step out of the Scripts folder

After this install jupyter in here using:在此安装 jupyter 之后,使用:

$ pip install jupyter

The installation was fine and when I tried to open the jupyter notebook, it gave me the following error.安装很好,当我尝试打开 jupyter notebook 时,它给了我以下错误。

'jupiter is not recognized as an internal or external command, operable program or batch file.

I checked a lot of resources but still, I faced the same problem.我检查了很多资源,但仍然面临同样的问题。 After doing a lot of stuff from the internet, I myself figured out that maybe due to some updates(for some users) it won't open by typing the command在从互联网上做了很多事情之后,我自己发现可能是由于一些更新(对于某些用户),它不会通过键入命令打开

jupyter notebook

Instead, you have to type相反,您必须输入

jupyter-notebook

The only thing I was missing was this Hyphen-minus.我唯一缺少的是这个连字符减号。 Hope this works for you too.希望这对你也有效。

If you are doing it through pip installation,如果你是通过 pip 安装,

C:\Users\<username>\AppData\Roaming\Python\<yourpythonfolder>\Scripts

Adding this to your path is missing for 'jupyter notebook' command to run缺少将此添加到您的路径以运行“jupyter notebook”命令

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM