[英]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.