简体   繁体   English

无法从笔记本下载.py 文件

[英]Cannot download .py file from Notebook

I am running Jupyter Notebook 6.1.0 and Python 3.8.5 on Windows 10. I create a simple Python file in Notebook and attempt to Download it as a.py file from the File Menu.我在 Windows 10 上运行 Jupyter Notebook 6.1.0 和 Python 3.8.5。我创建了一个简单的 Python 文件,并尝试从 Notebook 中将其下载为 File 文件。 Down in the lower left corner of the browser window, it seems to indicate it has saved it as a.py file.在浏览器window的左下角,似乎表明它已将其保存为.py文件。 But when I click there on Open File, a window opens and immediately closes.但是当我点击打开文件时,window 打开并立即关闭。 If I look at the directory where the.py file should be saved, there is a not a.py file with the expected name.如果我查看应该保存 .py 文件的目录,就会发现不是一个具有预期名称的 .py 文件。 There is only an.ipynb file with that name.只有一个具有该名称的 .ipynb 文件。

a python file is saved as a text file in the directory. python 文件保存为目录中的文本文件。 And the opening and closing is happening because it's the given output for that.并且打开和关闭正在发生,因为它是给定的 output 。

In Python 3, add the following to the end of your code:在 Python 3 中,将以下内容添加到代码末尾:

input('Press ENTER to exit') input('按回车键退出')

and open the file in a pycharm or your IDE edition.并在 pycharm 或 IDE 版本中打开文件。

I have a similar issue, but when I try to download as.py I get a file in my "Downloads folder" that has only 3 lines.我有一个类似的问题,但是当我尝试下载 as.py 时,我在“下载文件夹”中得到一个只有 3 行的文件。 (and these lines seem to be autogenerated, contains a "shebang" which is not in the notebook). (这些行似乎是自动生成的,包含一个不在笔记本中的“shebang”)。

Help about lists: You are using Jupyter notebook.关于列表的帮助:您正在使用 Jupyter 笔记本。

The version of the notebook server is: 6.0.3 The server is running on this version of Python: Python 3.8.3 (default, Jul 2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)]笔记本服务器的版本是:6.0.3 服务器运行在这个版本的Python上:Python 3.8.3 (default, Jul 2 2020, 17:30:36) (AMD64)] [MSC v.1916 66]

Current Kernel Information: Python 3.8.3 (default, Jul 2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)] Type 'copyright', 'credits' or 'license' for more information IPython 7.16.1 -- An enhanced Interactive Python.当前 Kernel 信息:Python 3.8.3(默认,2020 年 7 月 2 日,17:30:36)[MSC v.1916 64 位(AMD64)] 类型 'copyright',更多信息'license','credits'7。 1 -- 增强型交互式 Python。 Type '?'类型 '?' for help.求助。

Regards Hallvard问候霍尔瓦德

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

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