Python info and program(s) [2023-11-27]

When Microsoft announced and rolled out Python in Excel on September 2023, I started to learn Python programming language on September 2023, hoping to improve my work efficiency. 


Python and IDLE

The free 
Python v3.12.0 or higher version comes with a free Integrated Development and Learning Environment (IDLE). Python IDLE has 2 main windows: Shell window and the Editor window that provide the ability to write and execute Python codes from within IDLE. 

To show the line numbers in the IDLE, click Options > Configure IDLE > Shell/Ed. Check the "Show line numbers in new windows", click Apply button, follow by the OK button. The line numbers is useful during debugging the Python codes.

The free Python IDLE does not has a usable debugger. A debugger is a tool that allows a programmer to set places in a program 
(called breakpoints) where the program will stop and allow the programmer to see the value of variables, and allows the program to be executed a line at a time.

JetBrains PyCharm

Before installing the full-featured Python Integrated Development Environment (IDE) software, JetBrains PyCharm v2023.2.2 or higher version [for Windows 10 x64 1809 Operating System (OS) and later], please make sure that you have already installed Python first so that PyCharm will automatically set the Python interpreter in the IDE settings during the installation.

PyCharm has the Community Edition (free) and Professional Edition (paid). For Windows 7 x64 OS, you can install the PyCharm Community Edition v2019.3.5. 

As a beginning programmer, the free PyCharm 
Community Edition has everything that I need to write and debug Python codes.


Useful PyCharm shortcuts:

[F2] to go to the next highlight error in the file


Double [SHIFT] to open the Search Everywhere dialog.


[CTRL] d to Duplicate selected code block or the current line

[CTRL] e to show recently opened files

[CTRL] f to display the search bar

[CTRL] p to see the Parameter Info or method's signature

[CTRL] q to see the Quick code documentation for a class/method

[CTRL] w to select the Whole string

[CTRL] / to comment/uncomment any line

[CTRL] [SHIFT] / to comment/uncomment block comments


[CTRL] [SHIFT] f to open "Find in Files..."

[CTRL] [SHIFT] i to see the quick definition/content of the symbol at the caret

[CTRL] [SHIFT] j to join lines into one and remove unnecessary spaces

[CTRL] [SHIFT] r to open "Replace in Files..."

[CTRL] [SHIFT] v to paste from clipboard history

[CTRL] [SHIFT] [UP]/[DOWN] ARROW to move statement up/down


[CTRL] [SPACE] to activate basic completion explicitly. TAP completion

[CTRL] [SHIFT] [SPACE] to invoke Smart Completion


[CTRL] [ALT] [F7] to list all usages of a class, method or variable



PyInstaller

PyInstaller runs in Windows 8 and newer OS such as Windows 10 OS.

Assume Windows 10 x64 OS and had already installed Python 
v3.12.0 or higher version. Open a Command prompt (cmd). Install PyInstaller from PyPI:

pip install -U pyinstaller


After the Python codes (xxx.py) are tested to work correctly, I use the 
PyInstaller v6.0.0 or higher version to convert the Python codes (xxx.py) into executable Windows programs (xxx.exe) so that the Python scripts can run in any Windows OS computer without requiring a Python software installation.

Convert Python codes (xxx.py) into Windows programs (xxx.exe)

Assume Windows 10 x64 OS. Open a Command prompt (cmd). 
Set the current directory to the location of your program myscript.py and execute:

pyinstaller 
myscript.py

Your bundled application myscript.exe should now be available in the dist folder.


Error loading Python DLL python312.dll

In the computer running Win10 x64 v22H2 OS where I use

pyinstaller nYearsAndMonthsWorking_2023-10-04-R1.py

to convert 
nYearsAndMonthsWorking_2023-10-04-R1.py to nYearsAndMonthsWorking_2023-10-04-R1.exe that is located in the dist folder, the nYearsAndMonthsWorking_2023-10-04-R1.exe is running fine. 

However, when I try to run the nYearsAndMonthsWorking_2023-10-04-R1.exe at another computer running Win10 x64 OS that does not has Python software install, the below error appeared:

E:\> nYearsAndMonthsWorking_2023-10-04-R1.exe
Error loading Python DLL 'E:\_internal\python312.dll'.
LoadLibrary: The specified module could not be found.

To solve the above "Error loading Python DLL python312.dll" error, I use -F (Create a one-file bundled executable) option during converting:

pyinstaller -F nYearsAndMonthsWorking_2023-10-04-R1.py


Uninstall PyInstaller

Assume Windows 10 x64 OS. Open a Command prompt (cmd). 

pip uninstall pyinstaller


Python program(s)

Useful Python links:

Please donate. Thanks.


paypal.me/jackngch
(PayPal-to-Paypal account only)

Popular Posts