运行 在 Windows 上通过命令行使用 Jupyter
Running Jupyter via command line on Windows
我已经在 Windows 10 上安装了 Jupyter,Python 3.x 通过
$ pip install jupyter
安装工作正常,即使我确实重新启动了终端。
但正在尝试 运行
$ jupyter notebook
给出如下错误
'jupyter' is not recognized as an internal or external command, operable program or batch file.
如何以及在哪里找到 Jupyter 的可执行文件?
请先尝试其中一个命令;
$ py -m notebook
$ python -m notebook
jupyterlab 用户
py -m jupyterlab
否则
$ python -m pip install jupyter --user
$ jupyter notebook
如果这不起作用。
pip 不会直接将 jupyter 添加到本地路径。
来自
的输出
$ which python
/c/Users/<username>/AppData/Local/Programs/Python/Python35-32/python
经过一番挖掘,我在文件夹中找到了 jupyter 的可执行文件:
C:\Users\<username>\AppData\Roaming\Python\Python35\Scripts\jupyter.exe
Difference between local and roaming folder
所以如果你想通过命令行执行一个程序,你需要把它添加到%PATH 变量中。这是执行此操作的 powershell 脚本。请务必添加“;”在添加新路径之前。
$ [Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Users\<username>\AppData\Roaming\Python\Python35\Scripts", [EnvironmentVariableTarget]::User)
更新:
如果您使用的是 python3
,请将 python
换成 python3
但我鼓励您改用 pyenv
:)
如果您完全确定您的 Python 库路径在您的系统变量中(并且您可以在 pip install Jupyter 时找到该路径,您只需要稍微阅读一下)并且您仍然会遇到“ command not found or recognized”错误 Windows,你可以尝试:
python -m notebook
对于我的 Windows 至少 (Windows 10 Pro),拥有 python -m
是我可以 运行 我的 Python 包裹的唯一途径没有 运行 出现某种错误的命令行
Fatal error in launcher: Unable to create process using ' "
或
Errno 'THIS_PROGRAM' not found
如果您使用的是 Anaconda 发行版,请确保在安装它时选中 "Change PATH" 选项。
我在 Windows10 得到了 Jupyter notebook 运行ning。我发现完成这个任务最简单的方法是使用 Cygwin,而不依赖像 Anaconda 这样的发行版。
在 Cygwin 中安装 python2, python2-devel, python2-numpy, python2-pip, tcl, tcl-devel, (我有一张图片下面是我安装的所有软件包)和任何其他 python 您想要的可用软件包。这是迄今为止最简单的选择。
然后运行这个命令来安装jupyter笔记本:
python -m pip install jupyter
下面是我 运行 添加更多库的实际命令,以防其他人也需要此列表:
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
如果上述任何命令失败,请不要担心,大多数情况下解决方案都非常简单。您要做的是查看 build 是否存在任何丢失的包/库的故障。
说它显示缺少 pyzmq 然后关闭 Cygwin,重新打开安装程序,进入包列表屏幕,为所有显示 "full",然后搜索 zmq 之类的名称并安装这些库和重试上述命令。
使用这种方法,最终成功解决所有缺失的依赖项相当简单。
Cygwin package list
一旦所有东西都安装好了,然后在 Cygwin 中 运行 转到你想要成为笔记本 ui 树的 "root" 的文件夹并键入:
jupyter notebook
这将启动笔记本并显示如下输出:
$ 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
我遇到了同样的问题,但是
py -m notebook
对我有用。
我的问题是我用户的文件夹在文件夹名称中有一个 space。
创建新用户并切换到该 windows 用户后,Anaconda 中的 windows 快捷方式和链接工作正常。
Windows 8.1 64 位。最新的 Anaconda。
注意:我最终卸载了重新安装的 Anaconda,但我的感觉是问题实际上只是 windows 用户 username/user 文件夹中的 space。
在Windows10中可以使用ipython notebook
。对我有用。
您可以将以下内容添加到您的路径
C:\[Python Installation path]\Scripts
例如C:\Python27\Scripts
它将开始为 jupyter 和您将在此处执行的所有其他 pip 安装工作。
使用python 3.6.3。通过命令 'python -m pip install jupyter' 安装 Jupyter 后,'jupyter notebook' 命令对我不起作用使用 windows 命令提示符。
但是,最终'python -m notebook' 成功了,并在本地将 jupyter notebook 制作成了 运行。
以下是我解决上述问题的方法,希望对您有所帮助:
使用 python 的官方网站安装 python 3.7,同时安装包括通过选中它的框来安装 PATH
之后打开cmd(一定要在第1步之后打开)然后写入:pip install jupyter ENTER
现在您应该可以使用以下命令打开 jupyter notebook:jupyter notebook
看似简单,但也有帮助。
首先你应该确保你把你的 python 路径放在你的系统变量中..
然后试试运行这个
python -m pip install jupyter --user
然后
运行 这个
py -m notebook or jupyter notebook
我加了
c:\users\[user]\appdata\roaming\python\python37\site-packages
路径成功了。
在windows 10:
如果你使用anaconda3安装Jupyter notebook,安装时忘记勾选为系统添加环境变量,则需要手动在"Path"变量中添加如下环境变量:
(搜索 windows 编辑环境变量的设置")
Environment variables for Anaconda3
我的问题是我 运行 来自错误目录的 jupyter
命令。
导航到包含脚本的路径后,一切正常。
路径-
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\Scripts
## windows 命令
默认安装(安装时只需勾选 "add path" 和 "next")
python -m notebook
自定义安装在 C:\
jupyter notebook
如果你安装了jupyter
"python -m pip install jupyter" 命令
代替
“$ pip install jupyter”命令
然后按照以下步骤操作:
- 创建记事本
- 将其扩展名从“.txt”更改为“.ipynb”
- 右键单击它并单击 "open with"
- 在弹出窗口中,转到 - C:\Users\<"windows_user_name">\AppData\Roaming\Python\Python38\Scripts
- 点击"jupyter-lab.exe"
In Python 3.7.6 for Windows 10.安装后,我使用这些命令。
1. pip install notebook
2. python -m notebook
或
C:\Users\Hamza\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\Scripts
.
对于我的电脑 python-脚本位于上述路径中。您可以在环境变量中添加此路径。然后运行命令.
1. jupyter notebook
100% 工作解决方案:
按照以下步骤操作:
打开您下载 "python-3.8.2-amd64.exe" 安装程序或任何其他版本的 python 程序包的文件夹
双击“python-3.8.2-amd64.exe”
点击"Modify"
你会看到"Optional features"
点击"next"
Select "Add python to environment variables"
点击"install"
然后你可以 运行 jupyter 在任何你想要的文件夹中
E.g open "cmd" command prompt
Type :
E:
E:\>jupyter notebook
It will get started without showing
'Jupyter' is not recognized
谢谢
我安装了两个 python 版本:
1. Python 3.8.2: 这是独立安装的
2. Python 3.7.6:这是与 Anaconda 3 一起安装的
即使正确设置了路径变量,多个版本仍导致冲突。
我已经卸载了Python 3.8.2,重启后,命令
jupyter notebook
工作完美:)
检查你是否在环境变量中正确地给出了python PATH。
如果没有,则设置 python 路径。然后使用:
$ python -m notebook
我在 windows7 遇到了同样的问题,因为我刚刚在恢复点的帮助下恢复了我的电脑,然后笔记本就停止工作了。我试图更改路径设置,但没有任何效果,所以我只是简单地用安装它的应用程序卸载了 python,然后我再次安装了它。之后我再次安装了 jupyter notebook 然后它工作正常。
谢谢
您可以创建批处理文件并在 windows 搜索中搜索 Jupiter 并查看其属性,您将获得此字符串。
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 或任何驱动器中的脚本文件夹中,并将脚本文件的路径添加到您的环境路径中
然后您可以通过在 cmd 中输入 jupitor 轻松调用它。
我刚刚在我的 Python 3.8/pip 启用的 Win10 机器上安装了 JupyterLab,所以我 运行 遇到了 windows 这些启动问题。
如果一切正常(检查你是否有 Python 的 PATH,例如 C:\Users[Username]\AppData\Local\Programs\Python\Python38-32\Scripts)你只需 运行:
jupyter-lab.exe
就是这样。
干杯
安装我用过
windows 命令行
中的“pip install notebook”
To 运行 python -m notebook 对我没用,但是 python3 -m notebook 有用
首先运行这个命令
pip install jupyter
然后添加系统变量路径,这个路径就是jupyter等脚本所在的路径
PATH = C:\Users<用户名>\AppData\Roaming\Python\Python38\Scripts
例如 PATH=C:\Users\HP\AppData\Roaming\Python\Python38\Scripts
之后我们可以 运行 来自任何 folder/directory
的 jupyter
jupyter notebook
添加系统变量路径,这个路径是jupyter等脚本所在的路径
路径 -->
`C:\Users\<userName>\AppData\Roaming\Python\Python39\Scripts`
就像在我的笔记本电脑中一样 PATH 是:
"C:\Users\developer\AppData\Roaming\Python\Python39\Scripts"
之后,您将能够 运行 通过以下命令 运行 从任何文件夹和任何目录中运行 jupyter
jupyter notebook
我遇到了完全相同的问题,这让我发疯。其他答案提供了解决方案,但没有解释为什么你我会遇到这个问题。
我将尝试解释为什么会发生这种情况,然后提供一些解决方案。
你可以到最后看TL;DR.
这是怎么回事?为什么会出现此错误?
我将尝试逐步回答,以便清楚地解释所有内容。
如果一开始觉得太基础,请看本“文”的结尾。
我将首先从常见的事情开始,例如从终端 运行ning python
shell 或 运行ning pip
。你会明白为什么你可以从终端做到这一点,我们将在 为什么 和 如何 你可以 运行 jupyter
来自终端的笔记本。
准备好了吗?开始吧!
有没有想过为什么可以在终端(命令提示符)输入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.
>>>
您可能已经知道(但也许不知道)这是因为 Python 被添加到 Windows PATH
环境变量。您可能是在 installation time or afterwards.
完成的
但是,这个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.
您可以使用以下方法检查 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)
您可以看到这个文件夹:C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39
。这是安装Python 3.9版的地方。让我们检查一下它的内容:
<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à! 我们有 python.exe
文件(executable)。我们在 PATH
中有一个 Python 可执行文件,这就是为什么您只需键入 python
就可以从终端启动 Python 解释器。如果不是这种情况,您将不得不在终端中输入可执行文件的完整路径:
C:\Users\YOUR-USERNAME> C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\python)
而不只是:
C:\Users\YOUR-USERNAME> python
当你使用pip
时呢?
道理是一样的。您可以从终端 运行 pip
因为 PATH
变量中有一个 pip
可执行文件。
如果您转到 C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\Scripts\
(在上面显示的 PATH
中),您会看到许多可执行文件。其中之一是 pip
。实际上我有三个版本:pip
、pip3.9
和pip3
。
Scripts
folder 允许从终端 运行 执行文件。像 pip
或您打算直接从终端 运行 的其他库。 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.
If you put something there and it is properly in your PATH, then it
should be executable
该包装脚本将是 pip
可执行文件。 this executable 文件为 运行 时,它位于 Python 安装文件夹中的 pip
文件夹和 运行s pip
.
但您也可以直接从安装文件夹 (C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\Lib\site-packages
) 运行 pip
,而不需要可执行 pip
文件。
可是,你怎么做到的呢?
很高兴你提出这个问题。有一个Python way 到运行 模块作为主要模块(无需导入它)。
python -m pip
当你 运行 一个模块直接它的名字变成 __main__
。 -m
所做的是:
Search sys.path
for the named module and execute its contents as the __main__
module.
什么是__main__
?
'__main__'
is the name of the scope in which top-level code executes.
A module’s __name__
is set equal to '__main__'
when read from standard
input, a script, or from an interactive prompt.
...
我猜 pip
可执行文件做了类似的事情,或者至少具有相同的效果:启动 pip
.
这与 Jupyter Notebook 有什么关系?!
认为 Jupyter Notebook
与 pip
相同。如果你想在终端中 运行 jupyter
,你需要一个位于 PATH
.
上的可执行文件
我们已经看到 pip
或 jupyter
等模块的可执行文件位于此处 C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\Scripts\
.
如果我检查文件夹的内容,我会看到:
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
我看到已经提到的 pip
、pip3.9
和 pip3
。但是我没有看到 jupyter
(单独的单词“jupyter”)。
如果我在终端中输入 jupyter
,我会得到开始所有的错误:
'jupyter' is not recognized as an internal or external command, operable program or batch file.
您的问题终于有了答案!!!
'jupyter' 未被识别为命令,因为 Scripts
文件夹中没有名为 jupyter
.[=117 的可执行文件=]
所以,让我们试试不同的可执行文件。 jupyter-notebook
呢?
BINGO!笔记本是运行ning!
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).
我不知道为什么我没有名为 'jupyter' 的 jupyter
可执行文件。 official documentation 说要在终端上使用 jupyter notebook
,但似乎在某些情况下它不起作用。我认为这与我上面提到的有关:Scripts
文件夹中没有 jupyter
可执行文件。
如果你还记得的话,我告诉过你你可以 运行 pip
作为主模块使用 python -m pip
.
正好jupyter
也可以,我们只需要知道怎么调用就可以了。与 pip
一样,我们必须检查安装第 3 方库的文件夹:C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\Lib\site-packages
.
您会看到 jupyter_console
,但这只是在终端中创建了一个交互式笔记本,而不是您要找的东西。您还将找到以 .dist.info
结尾的文件夹,例如 jupyter_console-6.4.0.dist-info
。对于 JupyterLab
,这只是 metadata of the Wheel Binary Package builder. You'll also see a folder like jupyterlab_pygments
, but that's。我们想使用经典的 Jupyter notebook。
我们要的是运行notebook
。我们怎么知道的?
您将在文件夹 site-packages
中看到文件夹 (package) notebook
。里面有个file called __main__.py
:
#__main__.py
if __name__ == '__main__':
from notebook import notebookapp as app
app.launch_new_instance()
它正在调用 notebookapp.py
which is “基于龙卷风的 Jupyter 笔记本服务器。” 是的,这就是我们需要的。
我们可以see that launch_new_instance
in the notebookapp
calls launch_instance()
, which“启动 Jupyter 应用程序实例”。
完美!我们在正确的文件夹中。要从 Python 交互式 shell 运行 jupyter notebook,我们必须 运行 notebook 包:
python -m notebook
*** 总结:解决方案 ***
tl;博士:
我已经解释并展示了为什么会出现此错误。
现在总结一下解决方法:
要知道 jupyter
可执行文件的名称(在 Scripts
文件夹中),因此您可以 运行 直接从终端(命令提示符)作为:
jupyter notebook
或如:
jupyter-notebook
或者你的名字。
运行 作为主要模块的笔记本 来自 Python:
python -m notebook
我希望这对你有帮助,就像对我有帮助一样。我愿意接受您的意见和建议。
有同样的问题。最后搜索了 jupyter.exe 目录在我的电脑上的位置。由于某种原因,它在
C:\VTRoot\HarddiskVolume4\Users[用户]\AppData\Local\Programs\Python
而 Python 是
C:\Users[用户]\AppData\Local\Programs\Python
所以我将完整的 Python39 文件夹从 VTRoot 复制到 AppData 中的主 Python39 python 文件夹。问题已解决。
首先检查 python 的安装位置,方法是前往
C:\Users\**username**\AppData\Local\Programs\Python\Python39\Scripts
这是通常安装 python 的路径。在输入
之后
cd.. to get one step out of the Scripts folder
在此安装 jupyter 之后使用:
$ pip install jupyter
安装很好,当我尝试打开 jupyter notebook 时,出现以下错误。
'jupiter is not recognized as an internal or external command, operable program or batch file.
我检查了很多资源,但仍然遇到了同样的问题。在从互联网上做了很多事情之后,我自己发现可能由于一些更新(对于某些用户)它不会通过输入命令打开
jupyter notebook
相反,您必须输入
jupyter-notebook
我唯一缺少的是这个减号连字符。希望这对你也有用。
我刚刚在第一次安装和 运行 jupyter notebook 时发现了这个错误。然后我从中找到了可执行文件(.exe)
C:\Users\<user-name>\AppData\Local\Programs\Python\Python39\Scripts
。
实际文件名是 "jupyter-notebook"
。
安装指南将其描述为 "jupyter notebook"
到 运行 服务器。您必须在命令行中 运行 命令 "jupyter-notebook"
,它将是 运行。谢谢!
如果您是通过 pip 安装,
C:\Users\<username>\AppData\Roaming\Python\<yourpythonfolder>\Scripts
'jupyter notebook' 到 运行
的命令缺少将此添加到您的路径
我遇到了找不到 jupyter lab 的同样问题。
我试过了,python -m jupyterlab
我已经在 Windows 10 上安装了 Jupyter,Python 3.x 通过
$ pip install jupyter
安装工作正常,即使我确实重新启动了终端。
但正在尝试 运行
$ jupyter notebook
给出如下错误
'jupyter' is not recognized as an internal or external command, operable program or batch file.
如何以及在哪里找到 Jupyter 的可执行文件?
请先尝试其中一个命令;
$ py -m notebook
$ python -m notebook
jupyterlab 用户
py -m jupyterlab
否则
$ python -m pip install jupyter --user
$ jupyter notebook
如果这不起作用。
pip 不会直接将 jupyter 添加到本地路径。
来自
的输出$ which python
/c/Users/<username>/AppData/Local/Programs/Python/Python35-32/python
经过一番挖掘,我在文件夹中找到了 jupyter 的可执行文件:
C:\Users\<username>\AppData\Roaming\Python\Python35\Scripts\jupyter.exe
Difference between local and roaming folder
所以如果你想通过命令行执行一个程序,你需要把它添加到%PATH 变量中。这是执行此操作的 powershell 脚本。请务必添加“;”在添加新路径之前。
$ [Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Users\<username>\AppData\Roaming\Python\Python35\Scripts", [EnvironmentVariableTarget]::User)
更新:
如果您使用的是 python3
,请将 python
换成 python3
但我鼓励您改用 pyenv
:)
如果您完全确定您的 Python 库路径在您的系统变量中(并且您可以在 pip install Jupyter 时找到该路径,您只需要稍微阅读一下)并且您仍然会遇到“ command not found or recognized”错误 Windows,你可以尝试:
python -m notebook
对于我的 Windows 至少 (Windows 10 Pro),拥有 python -m
是我可以 运行 我的 Python 包裹的唯一途径没有 运行 出现某种错误的命令行
Fatal error in launcher: Unable to create process using ' "
或
Errno 'THIS_PROGRAM' not found
如果您使用的是 Anaconda 发行版,请确保在安装它时选中 "Change PATH" 选项。
我在 Windows10 得到了 Jupyter notebook 运行ning。我发现完成这个任务最简单的方法是使用 Cygwin,而不依赖像 Anaconda 这样的发行版。
在 Cygwin 中安装 python2, python2-devel, python2-numpy, python2-pip, tcl, tcl-devel, (我有一张图片下面是我安装的所有软件包)和任何其他 python 您想要的可用软件包。这是迄今为止最简单的选择。
然后运行这个命令来安装jupyter笔记本:
python -m pip install jupyter
下面是我 运行 添加更多库的实际命令,以防其他人也需要此列表:
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
如果上述任何命令失败,请不要担心,大多数情况下解决方案都非常简单。您要做的是查看 build 是否存在任何丢失的包/库的故障。
说它显示缺少 pyzmq 然后关闭 Cygwin,重新打开安装程序,进入包列表屏幕,为所有显示 "full",然后搜索 zmq 之类的名称并安装这些库和重试上述命令。
使用这种方法,最终成功解决所有缺失的依赖项相当简单。
Cygwin package list
一旦所有东西都安装好了,然后在 Cygwin 中 运行 转到你想要成为笔记本 ui 树的 "root" 的文件夹并键入:
jupyter notebook
这将启动笔记本并显示如下输出:
$ 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
我遇到了同样的问题,但是
py -m notebook
对我有用。
我的问题是我用户的文件夹在文件夹名称中有一个 space。
创建新用户并切换到该 windows 用户后,Anaconda 中的 windows 快捷方式和链接工作正常。
Windows 8.1 64 位。最新的 Anaconda。
注意:我最终卸载了重新安装的 Anaconda,但我的感觉是问题实际上只是 windows 用户 username/user 文件夹中的 space。
在Windows10中可以使用ipython notebook
。对我有用。
您可以将以下内容添加到您的路径
C:\[Python Installation path]\Scripts
例如C:\Python27\Scripts
它将开始为 jupyter 和您将在此处执行的所有其他 pip 安装工作。
使用python 3.6.3。通过命令 'python -m pip install jupyter' 安装 Jupyter 后,'jupyter notebook' 命令对我不起作用使用 windows 命令提示符。
但是,最终'python -m notebook' 成功了,并在本地将 jupyter notebook 制作成了 运行。
以下是我解决上述问题的方法,希望对您有所帮助:
使用 python 的官方网站安装 python 3.7,同时安装包括通过选中它的框来安装 PATH
之后打开cmd(一定要在第1步之后打开)然后写入:pip install jupyter ENTER
现在您应该可以使用以下命令打开 jupyter notebook:jupyter notebook
看似简单,但也有帮助。
首先你应该确保你把你的 python 路径放在你的系统变量中.. 然后试试运行这个
python -m pip install jupyter --user
然后 运行 这个
py -m notebook or jupyter notebook
我加了
c:\users\[user]\appdata\roaming\python\python37\site-packages
路径成功了。
在windows 10: 如果你使用anaconda3安装Jupyter notebook,安装时忘记勾选为系统添加环境变量,则需要手动在"Path"变量中添加如下环境变量: (搜索 windows 编辑环境变量的设置")
Environment variables for Anaconda3
我的问题是我 运行 来自错误目录的 jupyter
命令。
导航到包含脚本的路径后,一切正常。
路径-
C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\Scripts
默认安装(安装时只需勾选 "add path" 和 "next")
python -m notebook
自定义安装在 C:\
jupyter notebook
如果你安装了jupyter "python -m pip install jupyter" 命令 代替 “$ pip install jupyter”命令 然后按照以下步骤操作:
- 创建记事本
- 将其扩展名从“.txt”更改为“.ipynb”
- 右键单击它并单击 "open with"
- 在弹出窗口中,转到 - C:\Users\<"windows_user_name">\AppData\Roaming\Python\Python38\Scripts
- 点击"jupyter-lab.exe"
In Python 3.7.6 for Windows 10.安装后,我使用这些命令。
1. pip install notebook
2. python -m notebook
或
C:\Users\Hamza\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\Scripts .
对于我的电脑 python-脚本位于上述路径中。您可以在环境变量中添加此路径。然后运行命令.
1. jupyter notebook
100% 工作解决方案:
按照以下步骤操作:
打开您下载 "python-3.8.2-amd64.exe" 安装程序或任何其他版本的 python 程序包的文件夹
双击“python-3.8.2-amd64.exe”
点击"Modify"
你会看到"Optional features"
点击"next"
Select "Add python to environment variables"
点击"install"
然后你可以 运行 jupyter 在任何你想要的文件夹中
E.g open "cmd" command prompt
Type :
E:
E:\>jupyter notebook
It will get started without showing
'Jupyter' is not recognized
谢谢
我安装了两个 python 版本: 1. Python 3.8.2: 这是独立安装的 2. Python 3.7.6:这是与 Anaconda 3 一起安装的
即使正确设置了路径变量,多个版本仍导致冲突。
我已经卸载了Python 3.8.2,重启后,命令
jupyter notebook
工作完美:)
检查你是否在环境变量中正确地给出了python PATH。
如果没有,则设置 python 路径。然后使用:
$ python -m notebook
我在 windows7 遇到了同样的问题,因为我刚刚在恢复点的帮助下恢复了我的电脑,然后笔记本就停止工作了。我试图更改路径设置,但没有任何效果,所以我只是简单地用安装它的应用程序卸载了 python,然后我再次安装了它。之后我再次安装了 jupyter notebook 然后它工作正常。 谢谢
您可以创建批处理文件并在 windows 搜索中搜索 Jupiter 并查看其属性,您将获得此字符串。 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 或任何驱动器中的脚本文件夹中,并将脚本文件的路径添加到您的环境路径中
然后您可以通过在 cmd 中输入 jupitor 轻松调用它。
我刚刚在我的 Python 3.8/pip 启用的 Win10 机器上安装了 JupyterLab,所以我 运行 遇到了 windows 这些启动问题。 如果一切正常(检查你是否有 Python 的 PATH,例如 C:\Users[Username]\AppData\Local\Programs\Python\Python38-32\Scripts)你只需 运行:
jupyter-lab.exe
就是这样。
干杯
安装我用过 windows 命令行
中的“pip install notebook”To 运行 python -m notebook 对我没用,但是 python3 -m notebook 有用
首先运行这个命令
pip install jupyter
然后添加系统变量路径,这个路径就是jupyter等脚本所在的路径
PATH = C:\Users<用户名>\AppData\Roaming\Python\Python38\Scripts
例如 PATH=C:\Users\HP\AppData\Roaming\Python\Python38\Scripts
之后我们可以 运行 来自任何 folder/directory
的 jupyterjupyter notebook
添加系统变量路径,这个路径是jupyter等脚本所在的路径
路径 -->
`C:\Users\<userName>\AppData\Roaming\Python\Python39\Scripts`
就像在我的笔记本电脑中一样 PATH 是:
"C:\Users\developer\AppData\Roaming\Python\Python39\Scripts"
之后,您将能够 运行 通过以下命令 运行 从任何文件夹和任何目录中运行 jupyter
jupyter notebook
我遇到了完全相同的问题,这让我发疯。其他答案提供了解决方案,但没有解释为什么你我会遇到这个问题。
我将尝试解释为什么会发生这种情况,然后提供一些解决方案。
你可以到最后看TL;DR.
这是怎么回事?为什么会出现此错误?
我将尝试逐步回答,以便清楚地解释所有内容。 如果一开始觉得太基础,请看本“文”的结尾。
我将首先从常见的事情开始,例如从终端 运行ning python
shell 或 运行ning pip
。你会明白为什么你可以从终端做到这一点,我们将在 为什么 和 如何 你可以 运行 jupyter
来自终端的笔记本。
准备好了吗?开始吧!
有没有想过为什么可以在终端(命令提示符)输入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.
>>>
您可能已经知道(但也许不知道)这是因为 Python 被添加到 Windows PATH
环境变量。您可能是在 installation time or afterwards.
但是,这个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.
您可以使用以下方法检查 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)
您可以看到这个文件夹:C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39
。这是安装Python 3.9版的地方。让我们检查一下它的内容:
<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à! 我们有 python.exe
文件(executable)。我们在 PATH
中有一个 Python 可执行文件,这就是为什么您只需键入 python
就可以从终端启动 Python 解释器。如果不是这种情况,您将不得不在终端中输入可执行文件的完整路径:
C:\Users\YOUR-USERNAME> C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\python)
而不只是:
C:\Users\YOUR-USERNAME> python
当你使用pip
时呢?
道理是一样的。您可以从终端 运行 pip
因为 PATH
变量中有一个 pip
可执行文件。
如果您转到 C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\Scripts\
(在上面显示的 PATH
中),您会看到许多可执行文件。其中之一是 pip
。实际上我有三个版本:pip
、pip3.9
和pip3
。
Scripts
folder 允许从终端 运行 执行文件。像 pip
或您打算直接从终端 运行 的其他库。 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.
If you put something there and it is properly in your PATH, then it should be executable
该包装脚本将是 pip
可执行文件。 this executable 文件为 运行 时,它位于 Python 安装文件夹中的 pip
文件夹和 运行s pip
.
但您也可以直接从安装文件夹 (C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\Lib\site-packages
) 运行 pip
,而不需要可执行 pip
文件。
可是,你怎么做到的呢?
很高兴你提出这个问题。有一个Python way 到运行 模块作为主要模块(无需导入它)。
python -m pip
当你 运行 一个模块直接它的名字变成 __main__
。 -m
所做的是:
Search
sys.path
for the named module and execute its contents as the__main__
module.
什么是__main__
?
'__main__'
is the name of the scope in which top-level code executes.A module’s
__name__
is set equal to'__main__'
when read from standard input, a script, or from an interactive prompt. ...
我猜 pip
可执行文件做了类似的事情,或者至少具有相同的效果:启动 pip
.
这与 Jupyter Notebook 有什么关系?!
认为 Jupyter Notebook
与 pip
相同。如果你想在终端中 运行 jupyter
,你需要一个位于 PATH
.
我们已经看到 pip
或 jupyter
等模块的可执行文件位于此处 C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\Scripts\
.
如果我检查文件夹的内容,我会看到:
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
我看到已经提到的 pip
、pip3.9
和 pip3
。但是我没有看到 jupyter
(单独的单词“jupyter”)。
如果我在终端中输入 jupyter
,我会得到开始所有的错误:
'jupyter' is not recognized as an internal or external command, operable program or batch file.
您的问题终于有了答案!!!
'jupyter' 未被识别为命令,因为 Scripts
文件夹中没有名为 jupyter
.[=117 的可执行文件=]
所以,让我们试试不同的可执行文件。 jupyter-notebook
呢?
BINGO!笔记本是运行ning!
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).
我不知道为什么我没有名为 'jupyter' 的 jupyter
可执行文件。 official documentation 说要在终端上使用 jupyter notebook
,但似乎在某些情况下它不起作用。我认为这与我上面提到的有关:Scripts
文件夹中没有 jupyter
可执行文件。
如果你还记得的话,我告诉过你你可以 运行 pip
作为主模块使用 python -m pip
.
正好jupyter
也可以,我们只需要知道怎么调用就可以了。与 pip
一样,我们必须检查安装第 3 方库的文件夹:C:\Users\YOUR-USERNAME\AppData\Local\Programs\Python\Python39\Lib\site-packages
.
您会看到 jupyter_console
,但这只是在终端中创建了一个交互式笔记本,而不是您要找的东西。您还将找到以 .dist.info
结尾的文件夹,例如 jupyter_console-6.4.0.dist-info
。对于 JupyterLab
,这只是 metadata of the Wheel Binary Package builder. You'll also see a folder like jupyterlab_pygments
, but that's。我们想使用经典的 Jupyter notebook。
我们要的是运行notebook
。我们怎么知道的?
您将在文件夹 site-packages
中看到文件夹 (package) notebook
。里面有个file called __main__.py
:
#__main__.py
if __name__ == '__main__':
from notebook import notebookapp as app
app.launch_new_instance()
它正在调用 notebookapp.py
which is “基于龙卷风的 Jupyter 笔记本服务器。” 是的,这就是我们需要的。
我们可以see that launch_new_instance
in the notebookapp
calls launch_instance()
, which“启动 Jupyter 应用程序实例”。
完美!我们在正确的文件夹中。要从 Python 交互式 shell 运行 jupyter notebook,我们必须 运行 notebook 包:
python -m notebook
*** 总结:解决方案 ***
tl;博士:
我已经解释并展示了为什么会出现此错误。
现在总结一下解决方法:
要知道
jupyter
可执行文件的名称(在Scripts
文件夹中),因此您可以 运行 直接从终端(命令提示符)作为:jupyter notebook
或如:
jupyter-notebook
或者你的名字。
运行 作为主要模块的笔记本 来自 Python:
python -m notebook
我希望这对你有帮助,就像对我有帮助一样。我愿意接受您的意见和建议。
有同样的问题。最后搜索了 jupyter.exe 目录在我的电脑上的位置。由于某种原因,它在 C:\VTRoot\HarddiskVolume4\Users[用户]\AppData\Local\Programs\Python
而 Python 是 C:\Users[用户]\AppData\Local\Programs\Python
所以我将完整的 Python39 文件夹从 VTRoot 复制到 AppData 中的主 Python39 python 文件夹。问题已解决。
首先检查 python 的安装位置,方法是前往
C:\Users\**username**\AppData\Local\Programs\Python\Python39\Scripts
这是通常安装 python 的路径。在输入
之后cd.. to get one step out of the Scripts folder
在此安装 jupyter 之后使用:
$ pip install jupyter
安装很好,当我尝试打开 jupyter notebook 时,出现以下错误。
'jupiter is not recognized as an internal or external command, operable program or batch file.
我检查了很多资源,但仍然遇到了同样的问题。在从互联网上做了很多事情之后,我自己发现可能由于一些更新(对于某些用户)它不会通过输入命令打开
jupyter notebook
相反,您必须输入
jupyter-notebook
我唯一缺少的是这个减号连字符。希望这对你也有用。
我刚刚在第一次安装和 运行 jupyter notebook 时发现了这个错误。然后我从中找到了可执行文件(.exe)
C:\Users\<user-name>\AppData\Local\Programs\Python\Python39\Scripts
。
实际文件名是 "jupyter-notebook"
。
安装指南将其描述为 "jupyter notebook"
到 运行 服务器。您必须在命令行中 运行 命令 "jupyter-notebook"
,它将是 运行。谢谢!
如果您是通过 pip 安装,
C:\Users\<username>\AppData\Roaming\Python\<yourpythonfolder>\Scripts
'jupyter notebook' 到 运行
的命令缺少将此添加到您的路径我遇到了找不到 jupyter lab 的同样问题。
我试过了,python -m jupyterlab