0

I'm trying to 'Save and Export As Executable Script' a (.py) Jupyter Notebook, but the result is a blanc page and it doesn't export the file to anywhere. When I simply download the file, the result is a .py file but looks like this:

I need to upload an executable script of this file and I'd appreciate any help. Thank you.

4
  • 1
    This SE question sounds like what you're looking for. Commented Jun 13, 2024 at 13:39
  • 1
    I don't really use Jupyter myself, but FWIW, that's JSON, not Python code. Commented Jun 13, 2024 at 18:49
  • a jupyter notebook is an ipynb file. are you asking if you can convert this to a py file ? Commented Jun 13, 2024 at 18:58
  • Hi all, thanks for trying to help me out. Sorry, I'm totally new to the world of programming and I couldn't identity that I ended up with a JSON file after downloading my .py file from Jupyter. So I saved my .py file as .ipynb instead and when I download it I finally have my .py file as intended. Commented Jun 13, 2024 at 20:28

1 Answer 1

0

You should be able to convert any .py file to an .exe using PyInstaller. In the command line (assuming you have Windows), you can run pip install pyinstaller to install the conversion program. Then, run the following commands:

cd this\is\your\filepath
pyinstaller --onefile your_python_script.py

If that doesn't work, you can use AutoPy in the command line:

pip install auto-py-to-exe
auto-py-to-exe

This will allow you to use the AutoPy GUI to complete the conversion.

I don't think that the fact that your file is a Jupyter notebook should impact the method of conversion. For more detail on PyInstaller and AutoPy, check out this blog post.

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

1 Comment

"I don't think that the fact that your file is a Jupyter notebook should impact the method of conversion." It should because a Jupyter Notebook .ipynb file is json with code and possibly output stored in it. It isn't just python code, although there are things like Jupytext that make conversion straightforward as long as the code itself isn't using Jupyter conveniences and/or magics. nbformat can also easily be used to code a small script to extract the code, see here.

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.