Jac*_*Dev 5 python python-3.x jupyter visual-studio-code jupyter-notebook
我的 Windows 10 计算机上安装了现有的普通 Python,但我不想重新安装 Anaconda。
当尝试在 vscode 中运行 ipynb 文件中的代码时,出现以下错误:
Error: Jupyter cannot be started. Error attempting to locate jupyter:
at A.startServer (c:\Users\[username]\.vscode\extensions\ms-python.python-2020.2.64397\out\client\extension.js:1:786120)
at async A.ensureServerAndNotebookImpl (c:\Users\[username]\.vscode\extensions\ms-python.python-2020.2.64397\out\client\extension.js:1:785575)
at async A.ensureServerAndNotebook (c:\Users\[username]\.vscode\extensions\ms-python.python-2020.2.64397\out\client\extension.js:1:785376)
at async A.submitCode (c:\Users\[username]\.vscode\extensions\ms-python.python-2020.2.64397\out\client\extension.js:1:782328)
at async A.reexecuteCell (c:\Users\[username]\.vscode\extensions\ms-python.python-2020.2.64397\out\client\extension.js:75:879318)
Run Code Online (Sandbox Code Playgroud)
以下是我尝试过的一些事情:
检查VSCode扩展是否正确安装
“Jupyter”扩展已被弃用。我安装了 Microsoft 的“Python”插件,其中包含 Jupiter Notebook 支持。
Jupyter安装正确
我尝试重新安装 jupyter:
> python -m pip install --upgrade pip
> pip install jupyter
> pip install notebook
Run Code Online (Sandbox Code Playgroud)
尝试在终端/命令行上运行 Jupyter
> jupyter notebook //didn't work
jupyter : The term 'jupyter' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ jupyter
+ ~~~~~~~
+ CategoryInfo : ObjectNotFound: (jupyter:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)
这给出了无法找到 jupyter 可执行文件的错误。根据这篇文章,我尝试了以下方法并且有效:
> python -m notebook
Run Code Online (Sandbox Code Playgroud)
检查是否指向正确的解释器
根据这篇文章我尝试过:
但我的计算机上只安装了一个版本的 Python,这样做并没有什么区别。
检查路径
这篇文章PYTHONPATH中有这样的评论,但由于 python 目录被正确引用并且可以从命令行工作,所以我没有进一步调查它。python
需要注意的一件事是pip安装到我的"C:/Users/[username]/appdata/Roaming/Python-38/"文件夹,而我的 Python 安装在"C:\Program Files\Python38-32\".
如果您遇到类似问题,请尝试问题中提到的上述步骤。
阅读本文后,我意识到我还必须映射使用 pip 安装的脚本,即使它位于我的漫游目录中。https://discuss.python.org/t/windows-appdata-roaming-vs-local/2682。这种混乱让我花了很多时间。
添加变量的步骤如下:
最后重新启动 VSCode,以便为 VSCode 更新新的环境变量。现在运行 ipynb 文件中的脚本,它应该可以工作。它还可能会抱怨它需要其他模块,在这种情况下您可以使用“pip”来安装它。
注意:如果您不受计算机上现有 python 版本的限制并且不想安装更多版本,您也可以使用 Python Anaconda Distribution。https://www.anaconda.com/distribution/
注意:如果您希望 jupyter note 适用于使用您计算机的所有用户,您需要配置 pip 将安装下载到不在“C:\Users[用户名]”文件夹中的目录,并向其中添加系统变量。
| 归档时间: |
|
| 查看次数: |
19815 次 |
| 最近记录: |