Python Bootstrap

Boostrap version of Python-2.7 for Windows.

AppVeyor Build Status

Quickstart

Python Boostrap is ready to go. Just download it to your Windows PC, extract the zip file anywhere and doubleclick python.exe.

Responsive image

About

There was a need for an edition of Python-2.7 that could be installed on a Windows computer without administrative rights so I scripted some glue to combine the steps already part of Python.

  1. getting and building externals like tcl/tk, sqlite3, bzip, etc., so easy with the buildbot externals tools batch scripts 
  2. building Python, easy with the PCbuild batch scripts 
  3. coallating the files into the conventional structure, basically copy and paste 

For more detail read Building Python x64 on Windows 7 with SDK 7.0 and Python issue 22516: Administrator rights required for local installation .

Build

Python Bootstrap is build from the most recent tag of the 2.7 branch of the cpython repository at the Python Mercurial Repositories and Microsoft Visual Studio 2008 compilers from the Windows SDK for Windows 7 and .NET Framework 3.5 SP1 on an AppVeyor CI build worker.

Contributions

Contribute to the Python Bootstrap AppVeyor build and these web pages on Bitbucket.

Alternatives

Usage

Here are a few extra steps to make Python Bootstap even easier.

Download

When you click the download link you'll see a list of the most current distributions. The name indicates the platform, either x86 (32-bit) or x64 (64-bit, AKA: amd64), and the version, EG: 2.7.10. Only Python-2.7.X distributions are available at Python Bootstrap, because there are already plans to release installers for Python-3.5 that don't require administrative rights. Usually your browser will download internet files to your profile's Downloads folder, EG: C:\Users\username\Downloads. You may be prompted to Keep the download, or even to select where you would like to download the zip file to. Click the Python Bootstrap version you want and pay attention to where it's saved.

Extraction

Find the Python Bootstrap zipfile on your computer, probably in Downloads and right click it. Select Extract All ... and change the destination to C:\. The standard location for python.exe is C:\Python27, but actually you could put it anywhere. For now though let's assume it's in the standard location. If you are only using one version of Python, then change the name of the folder to Python27. If you are using both versions, pick one to be the default, and change its name to Python27. Using the common name for the default Python will be easier.

User PATH Environment Variable

You'll need to add C:\Python27 and C:\Python27\Scripts to you path. If you didn't change the name of the default Python folder to Python27, or if you chose to go rogue and put Python in some non-standard location, then you will have to put the correct full path to the location of python.exe in your user PATH evironment variable. From the Windows Start Menu click Control Panel and open User Accounts. You might have to click User Accounts in two places, depending on your Control Panel display defaults. Eventually you should see a page with Change my environment variables in the left margin.

Responsive image

Clicking Change my environment variables brings up the Environment Variables dialogue. It's split into two sections, User and System variables. You may or may not already have a PATH variable in the User section. In addition, PATH might be ALL CAPITAL LETTERS, all lowercase or Titlecase IE: Path. Windows is case insensitive, so all of these are equivalent. Just be careful not to add another PATH if you already have it in a different case.

Responsive image

Python Package Installer

Python comes with a nifty package installer called affectionately pip, but before it will work it needs to be installed. From the Windows Start Menu open a Windows Command Prompt window either by navigating All Programs -> Accessories -> Command Prompt or by simply typing CMDin the Search box.

Responsive image

In the Windows Command Prompt type python -m ensurepip followed Enter. You should see the following displayed in the command window, indicating that both pip and setuptools, a dependency have been installed.

  Ignoring indexes: https://pypi.python.org/simple
  Collecting setuptools
  Collecting pip
  Installing collected packages: setuptools, pip
  Successfully installed pip-6.1.1 setuptools-15.2
      

Visual C++ Compiler for Python 2.7

The last step is to get the free Microsoft Visual C++ Compiler for Python 2.7, so that almost any package can be installed by pip, even if it has enhancements, or speedups written in C++, which Python also understands, but needs to be compiled by your computer before Python can use it. Go to:

http://www.microsoft.com/en-us/download/details.aspx?id=44266
and download VCforPython27.msi. Double click it to install. No admin rights required, just follow directions and accept all defaults.

Primer

Read my Python Primer for a list of links, tutorials and references.

IDLE

Python comes with IDLE, an IDE with syntax highlighting, autocompletion, debugging and more. You can start IDLE by double clicking C:\Python27\Scripts\idle.bat. Or if you added C:\Python27\Scripts\ to your PATH environment variable then typing idle.bat will also start IDLE. Click File->New File from the menu bar in IDLE to open an editor.

Responsive image Responsive image

*.py file association

Make your first Python program by starting IDLE, opening a new file and copying the program in the image above into the editor. From the menu bar save the program in your Documents folder as helloworld.py. Open your Documents in Windows Explorer and right click on helloworld.py select Open with then Choose default program. Make sure "always use the selected program ..." is checked and then click the Browse button to locate C:\Python27\python.exe. Click the OK button to save the changes. Notice the icon for helloworld.py is now the Python logo.

Registry Keys

Yes, sadly Python on Windows uses registry keys, but that's good because it lets you do things like integrate Python into Explorer context menus. You can also register extensions like we did in with *.py file association. More specifically, some programs expect there to be some metadata with specific keynames in the registry. You can add these with out admin rights to your HEY_KEY_LOCAL_USER\SOFTWARE keys by opening the Windows start menu and typeing regedit into the search box and hitting enter. Search for HKCU\SOFTWARE, then right click and select Add Key and type Python. Repeat on that key and add PythonCore. Repeat again on PythonCore and add InstallPath. Then this time, double click default value and enter C:\Python27\ or whatever the path to your base Python folder is, ie: whichever folder has python.exe. Enter the rest of the keys using the registry file below. Alternately you can copy the text below into a file called hkcu_software_python_pythoncode.reg, right click it and select merge keys. If you are using the x86 version, then you must use the registry editor in C:\Windows\SYSWOW64 also called regedit.exe. Oh yah, maybe make a backup of your registry before editting it.

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\Help]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\InstallPath]
@="C:\\Python27\\"
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\InstallPath\InstallGroup]
@="Python 2.7"
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\Modules]
[HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\PythonPath]
@="C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk"
      

Embeddable Python

You can make a stripped down version of python to distribute with your applications that zipped is less than 20MB.

  1. Copy all .pyd files from DLL folder to the top folder C:\Python27.
  2. Open the Lib folder, select all and send it to a zip archive called python27.zip. Then copy the archive to the top folder C:\Python27.
  3. Delete all folders but libs, Scripts and tcl
  4. To use it, just add you packages to the top folder C:\Python27, scripts to scripts and just call your application from a batch file that calls the embedded pythone.exe with your script. You make need to tweek your Python paths.

Removal

Just nuke C:\Python27 and your Bootstrap Python installation will be obliterated forever.