1

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?

3
  • If you just type python --version in your shell what output do you get? It might be that the Python being used in your Jupyter Notebook is not the same one as in your terminal, in which case you won't have the same libraries installed and would have to either specify to run it with the Anaconda Python interpreter, or install the same libraries in the Python interpreter being used by default in your terminal. Commented May 4, 2019 at 16:29
  • To Mihai Chelaru: I got: Python 2.7.15rc1 Commented May 4, 2019 at 16:36
  • Okay, so you ran the script using python3? You can use whereis python3 and get the path to the python executable you used to run the script in your terminal. Then in your Jupyter notebook you can create a cell containing import sys followed by sys.executable and run that to get the path to the interpreter used by Jupyter. If they're different then that's your problem. Commented May 4, 2019 at 16:41

1 Answer 1

2

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.

enter image description here

Sign up to request clarification or add additional context in comments.

5 Comments

This answer should really be a comment. You should not use answers to ask the OP questions, but rather should provide a solution that does not require input from the OP.
@MihaiChelaru thanks for your comment, and I have edited my answer, and now I have tried to provide asolution
I installed the package: sudo apt install python3-pip. And now after entering the command: python --version I get: Python 3.7.1.
@Denis please check the version of python in jupyter (as I have shown in the picture) which is giving you the desired output.
In Jupyter Notebook I use Python 3. Now i installed the pandas library: pip3 install pandas, and now I get errors related to the lack of other software library. How do I understand now I need to install each library separately via pip3?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.