Portable Apps & Portable Python¶
So I wanted to do some programming in python whilst at work I could have used my netbook but its size can make it difficult to work on for serious code generation. So my decision was to use Portable Apps from a USB memory stick, Portable Apps does not include Python in its package listing. A quick scout about with a popular search engine showed Portable Python as a solution a current Python version bundled with some handy modules.
The easy bit is to use the Windows installer for each package to install them on the memory stick, Portable Apps installed first and then Portable Python into the root of the drive. Setting up the working environment is the next task. Portable Python includes a couple of Python Shells but what would be better is integrating them into the command line. Installing Command Prompt Portable is the answer, this is a command line on the USB stick to which the batch file it runs at startup can be altered to allow the Python Path to be set.
The batch file is located for me at M:/PortableApps/CommandPromptPortable/Data/Batch/commandprompt.bat.
1 2 3 4 5 6 7 8 9
@echo off set PYTHONHOME=%~d0\PortablePython_1.1_py2.6.1\App\\ set PATH=%PATH%;%~d0\PortablePython_1.1_py2.6.1\App\;%~d0\PortablePython_1.1_py2.6.1\App\Scripts;%~d0\Documents color 07 prompt $p$g title My Command Prompt cls ver cd\\
Lines 2 & 3 are the ones I added, they add the path to Python on the USB stick. Note the “%~d0” this picks up the drive letter from the location of the bat file. As its on the memory stick it takes that drive letter. Coding it in this way means that no matter what drive letter the USB stick is given it will always set the correct paths. The paths have basically been set to allow Python access to the Python executable itself, its scripts directory and the Documents location for user scripts.