简体   繁体   中英

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

I wrote a Python program in Jupyter Notebook. The program uses libraries installed through Anaconda. I need to get a separate executable Python file that would work on forks of Ubuntu and Debian. I created the .py file from the .ipynb file through the menu in the Jupyter Notebook:

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

Next, I try to run .py file through the Terminal in Linux:

>>> 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.

How to get a working program separately from 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 . Your issue might be because of two different python versions.

Depending upon your version of python in local machine, you might have to use the same version of pip to install pandas .

Check the version of python you are running in Jupyter.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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