Hey Bing Chat: How can I compile a Python program into an executable file?

Bing Chat is an AI alternative to Chat-GPT. I’ve been testing it quite a bit since, at least for now, it is completely free and in most cases does an excellent job.

Here is a test case that worked perfectly for me…

Prompt: How can I compile a Python program into an executable file?

There are several ways to compile Python code into an executable file. One of the most popular ways is to use PyInstaller² which can be installed using pip package manager². Once installed, you can use it to create an executable file by running the following command in your terminal:

pyinstaller yourscript.py

This will create a folder named “dist” in your current working directory which will contain your executable file².

Another way to compile Python code into an executable file is to use auto-py-to-exe¹. You can install it using pip package manager and then launch it by entering “auto-py-to-exe” into cmd¹. Once launched, you can select the python script path into Script Location field and decide whether you need the exe file as One Directory or as one file¹.

Source: Conversation with Bing, 3/30/2023

(1) How to Turn Your Python Code into an Exe on Windows – Mouse Vs Python. https://www.blog.pythonlibrary.org/2021/05/27/pyinstaller-how-to-turn-your-python-code-into-an-exe-on-windows/ Accessed 3/30/2023.

(2) How to Compile Python to Exe ? 3 Methods – Data Science Learner. https://www.datasciencelearner.com/how-to-compile-python-to-exe/ Accessed 3/30/2023.

(3) How to compile Python to exe | Code Underscored. https://www.codeunderscored.com/compile-python-exe/ Accessed 3/30/2023.

(4) How to Compile Python Script (with Pictures) – wikiHow. https://www.wikihow.com/Compile-Python-Script Accessed 3/30/2023.

(5) How can I convert a .py to .exe for Python? – Stack Overflow. https://stackoverflow.com/questions/41570359/how-can-i-convert-a-py-to-exe-for-python Accessed 3/30/2023.

(6) Create Executable of Python Script using PyInstaller. https://bing.com/search?q=how+to+create+an+executable+file+from+python+code Accessed 3/30/2023.

(7) Two Simple Methods To Convert A Python File To An Exe File. https://www.datacamp.com/tutorial/two-simple-methods-to-convert-a-python-file-to-an-exe-file Accessed 3/30/2023.

(8) How do I make an executable from a Python script?. https://www.tutorialspoint.com/how-do-i-make-an-executable-from-a-python-script Accessed 3/30/2023.

(9) How to Easily Convert a Python Script to an Executable File (.exe). https://towardsdatascience.com/how-to-easily-convert-a-python-script-to-an-executable-file-exe-4966e253c7e9 Accessed 3/30/2023.

Prompt: Using pyinstaller, can my Python program be compiled into a single file?

Yes, it can be compiled into a single file. You can use PyInstaller to create a single executable file by using the “–onefile” option. Here’s an example command:

pyinstaller --onefile yourscript.py

This will create a single executable file in the “dist” folder of your current working directory.


Absolutely! It worked perfectly with a simple file management program I wrote. Just like the tip above mentioned it would do, it created an exe file in a dist folder that it created that I was able to copy to my Desktop to make it more convenient to run.

An abstract image about a person asking an AI chat program about how to compile a Python program into a single file, digital art
Created with Bing Image Creator. Prompt: A person asking an AI chat program about how to compile a Python program into a single file, digital art

Converting Lists of Data to CSV — Using a Colab Notebook Hosted in Gists

I’ve really been enjoying learning about data analysis lately. Part of what’s made it so enjoyable is the use of Colab, which is Google’s version of Jupyter Notebook.

I came across a need to convert some lists of data to a CSV (comma separated values) format so I could paste it into a Google Sheet. Not finding anything online to do I decided to write my own, and here is the product.

The Colab notebook I created has been saved as a “gist”, which is GitHub’s cousin for fast and easy file storage service. The Gist website is also very popular for sharing CSV files, which this search will attest to.

You’ll notice an “Open in Colab” button at the top, which is how you will open the document. A really nice feature is that it is fully usable without needing to save the file anywhere, but for those that do want to save their work, they can, into Google Drive.

When you first run it, you’ll get a scary message that was written by Google’s lawyers. You’ll see from the source code that the notebook’s not doing anything nefarious, so just trust me and click on “Run Anyway”. 😆

Google Colab Warning

This is a preview of the notebook. To open it, click here or on the filename on the bottom left corner of the preview.

Some Python programmers may want to remind me that I could have used Python’s built-in CSV library, but I felt Pandas would be faster, especially for large lists.

I hope some of you find this useful, although I’ll be happy if it gets some of you interested in Colab for Python programming or for data analysis, or even if it just introduces you to the Gist website.

Integrating Google Drive into Google Colab Notebooks

Why might we want to integrate Google Drive into Google Colab? The primary reason for this would be to easily access data files to use in your Colab notebooks. 

Here is a video that outlines the basic process. For written instructions, see below.

Integrating Google Drive into Google Colab is quite simple. The first step is to go to Google Colab, then open a new notebook.

Continue reading “Integrating Google Drive into Google Colab Notebooks”

#100DaysOfCode – Come Join the Fun!

Have you wanted to learn how to program but lacked the support? #100DaysOfCode is a formal (but flexible) process with a clear set of rules designed to motivate you. Part of the process involves sharing your goals and progress via social media and your files via GitHub, which is a free online repository website and version control service which many teachers are now using as an alternative to a traditional website.

Come learn how to get started and how the process works. You’ll especially benefit from this session if you never used GitHub and want to learn how easy it can be. Continue reading “#100DaysOfCode – Come Join the Fun!”

Relational Databases – How to Choose

Relational Database Comparison screenshot

As a Python programmer and teacher, I’m always on the hunt for good tutorials. Some of the best Python tutorials I found are on a YouTube channel named Socratica. For these videos they have a McGill CS graduate & actress named Ulka Simone Mohanty [@ulkaM | resume] whose character is a quirky, robot-like narrator with a very dry sense of humour, which for me, makes the videos especially entertaining.

In my YouTube subscription alerts I saw that Socratica has just released some new videos related to SQL databases. If they’re as good as their Python series I had to check them out.

It was nice to see that they are also using Ulka to narrate this series. And it’s nice to see that the videos are just as entertaining (and informative) as the Python series.

I have some experience programming in MySQL (thanks to Dr Chuck) so was really interested in its popularity vs PostgreSQL and MariaDB. The video is only an overview, but it’s enough to whet my appetite about revisiting my old My SQL programs and seeing how difficult they are to convert to the other formats. It also gets me thinking about investigating free accounts in the cloud for any databases I write.

I’d love to hear what you think about these videos. Do you find them as entertaining and informative as I do?

(Credit to the video for the screenshot used above)