简体   繁体   English

如何从.ipynb(Jupyter Notebook)制作可执行的Python文件?

[英]How to make executable Python file from .ipynb (Jupyter Notebook)?

I wrote a Python program in Jupyter Notebook. 我在Jupyter Notebook中编写了一个Python程序。 The program uses libraries installed through Anaconda. 该程序使用通过Anaconda安装的库。 I need to get a separate executable Python file that would work on forks of Ubuntu and Debian. 我需要获得一个单独的可执行Python文件,该文件可以在Ubuntu和Debian的分支上工作。 I created the .py file from the .ipynb file through the menu in the Jupyter Notebook: 我通过Jupyter Notebook中的菜单从.ipynb文件创建了.py文件:

File -> Download as -> Python (.py).

Next, I try to run .py file through the Terminal in Linux: 接下来,我尝试通过Linux的终端运行.py文件:

>>> python3 name_of_created_file.py

And I get an error: 我得到一个错误:

Traceback (most recent call last):
  File "name_of_created_file.py", line 11, in <module>
    import pandas as pd
ModuleNotFoundError: No module named 'pandas'

As I understand it, there are not enough software libraries to run the program. 据我了解,没有足够的软件库来运行该程序。 On the same computer (Linux) in Jupyter Notebook, my program works well. 在Jupyter Notebook的同一台计算机(Linux)上,我的程序运行良好。

How to get a working program separately from Jupiter Notebook? 如何与Jupiter Notebook分开获得工作程序? To do this, I need to separately install software libraries? 为此,我需要单独安装软件库吗?

Can you please check the version of python in your local, whether python or python3 . 您能否在本地检查python的版本,无论是python还是python3 Your issue might be because of two different python versions. 您的问题可能是由于两个不同的python版本。

Depending upon your version of python in local machine, you might have to use the same version of pip to install pandas . 根据本地计算机上的python版本,您可能必须使用相同版本的pip来安装pandas

Check the version of python you are running in Jupyter. 检查您在Jupyter中运行的python版本。

在此处输入图片说明

暂无
暂无

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

相关问题 如何从 Jupyter 笔记本上的 * .IPYNB 文件执行 * .PY 文件? - How to execute a * .PY file from a * .IPYNB file on the Jupyter notebook? 如何直接从终端创建和打开 jupyter notebook ipynb 文件 - How to create and open a jupyter notebook ipynb file directly from terminal vscode:如何自动缩进jupyter notebook ipynb文件? - vscode: how to autoindent jupyter notebook ipynb file? 如何从终端运行 an.ipynb Jupyter Notebook? - How to run an .ipynb Jupyter Notebook from terminal? 如何从 jupyter 笔记本制作一个 python 可执行文件,从配置文件读取要在主程序中读取的文件路径? - How to make a python executable file from jupyter notebook that reads path of files to be read in the main program from a configuration file? Jupyter Notebook:文件“ .ipynb_checkpoints”不存在-Python - Jupyter Notebook: File “.ipynb_checkpoints” does not exist - Python 从 Jupyter Notebook 上的 .ipynb 文件执行位于隐藏文件夹中的 python 脚本 (.py) - Execute a python script (.py) located inside a hidden folder from a .ipynb file on Jupyter Notebook 从命令行运行 Jupyter Notebook (.ipynb),就好像它是一个 .py 文件一样 - Run Jupyter Notebook (.ipynb) from command line as if it were a .py file 如何在 jupyter notebook 中将一个 ipynb 文件中定义的变量访问到另一个文件中? - How to access variables defined in one ipynb file into another in jupyter notebook? 如何从运行 PySpark 内核的 EMR jupyter notebook 中的另一个 ipynb 文件导入? - How to import from another ipynb file in EMR jupyter notebook which runs a PySpark kernel?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM