Pyportable is a portable Python programming environment (http://python.org) that runs from a local folder or a USB device, without the normal installation process common in Windows, and no admin priveledges needed.
If you just want to use a portable version of Python, download the latest release, unzip it in a folder, and run the terminal.bat launcher script. Pip will be available in the command line.
- Pyportable-2.7.10rc1: https://github.com/sganis/pyportable/releases/download/v2.7.10rc1/pyportable-2.7.10rc1.zip
I got the inspiration from the excellent work at portable python. The motivations to fork the original project were the need to have an updated portable version of python 2.7 in Windows, 64-bit packages, maximize the use of pip, and also make the build script simpler. I tried to simplify the original project as much as possible. There is only one short script. However, it is less tested, too. Only 64-bit Windows 7/8/8.1, and Windows Server 2008/2008R2/2012/2012R2. I also only tested in machines with some version of Visual Studio installed, and I guess this might satisfy some dependencies, so more tests in fresh Windows machines are needed.
The steps of creating a portable python are as follows:
- Download and extract python.
- Set the new PATH environment variable so you python is the new executable just donwloaded.
- Download pip and install it. This became quite simple with the git-pip.py script. Setuptools will be installed too. The only problem is that pip will not be portable, the executable is saved in the Scripts directory and it has the full path of the python interpreter hard-coded. To make pip portable, we need to change that path. See below.
- Download numpy wheel. I am using the latest build from UCI. I decided to use this precompiled package because it requires some extra libraries such as atlas, lapack, blas, as well as Intel® Math Kernel Library and the runtime libraries for Intel C++ and Fortran, and didn't want to setup such building environment. In addition, these packages will install almost all dependencies needed for many other packages.
- Use pip to install the rest of packages.
Packages with C extensions will require compilation if a pre-build wheel is not available, such as Cython and Pycrypt. Pip will build it if you have a compiler. The trick is to install Microsoft Visual C++ Compiler for Python 2.7. It might work with any Visual Studio (I have version 2012), but you need to do some configuration so pip can find the compiler. Make sure it works for 64-bits typing in the command line:
c:\> cd c:\wherever\the\msvc\compiler\is\located>
c:\wherever\the\msvc\compiler\is\located> vcvarsall.bat amd64
Setting environment for using Microsoft Visual Studio 2008 x64 tools.
In my machine, I only needed to do this:
c:\pyportable> SET VS90COMNTOOLS=%VS110COMNTOOLS%
But sometimes take longer to setup the compiler. The important thing is that the script vcvarsall.bat must be available in your path, usually located somewhere in C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC or something similar. That script will be called from pip to set some variables such as new PATH, LIB, LIBPATH, INCLUDE..., all this needed for the MSVC compiler.
If you do not have a compiler, then the other option is to find a wheel with a pre-build release, such as those at UCI. You can use pip directly with an url:
c:\pyportable> set UCI=http://www.lfd.uci.edu/~gohlke/pythonlibs/r7to5k3j
c:\pyportable> pip install %UCI%/pandas-0.16.1-cp27-none-win_amd64.whl
In this example, numpy must be installed before to satisfy dependencies.
The build.bat script will do everything, ending up with a portable version of python. It downloads packages from internet if needed, executes the steps from above, and creates a self-extracting executable. Run the script from a windows terminal:
c:\pyportable> build.bat
I followed the steps at http://www.clemens-sielaff.com/create-a-portable-python-with-pip-on-windows. The patchpip.py script automates the process.