I am running PortablePython_1.1_py2.6.1 on a USB stick. My code relies on some modules that are not preinstalled. Does anyone know whether it is possible to add new modules to a portable python installation? Simply copying in folders into site-lib does not seem to work.
3 Answers
What does import sys; print sys.path
say? It should be the list of directories and zipfiles where Python (portable or otherwise) looks for modules to import. Just copy your modules into one of those directories or zipfiles, or sys.path.append('/whatever/dir')
if you have your modules in /whatever/dir
and want to keep them there (the latter approach will last only for the current session, be it interactive or a script's execution).

- 854,459
- 170
- 1,222
- 1,395
-
This deos not work for me : >>> import sys; print sys.path File "
", line 1 import sys; print sys.path ^ SyntaxError: invalid syntax – Stéphane Laurent Aug 29 '12 at 09:47 -
And so, once I know these path names, how to install a module please ? – Stéphane Laurent Aug 29 '12 at 09:50
-
I download the zip archive of a module, I put it in one of those directories, and that does not work. What do I have to do in addition ? – Stéphane Laurent Aug 29 '12 at 10:05
This closed question was actually asked for Portable Python 3.2. I have found a nice way to install modules with Windows :
download the zip archive of the distribute module
install it by typing
MyPythonPath\App\python MyDownloadPath\setup.py install
in a DOS commander
Now Easy Install is installed in folder MyPythonPath\App\Scripts. So type e.g.
MyPythonPath\App\Scripts\easy_install-3.2 numpy
to install the numpy module.

- 1
- 1

- 75,186
- 15
- 119
- 225
This question is old and maybe this is a possibility that was not possible at this time but simply:
- From a command prompt go to your Portable Python's python.exe folder with
cd <path to Portable Python>\App\Python
, - Run (for instance to install
selenium
module):.\python.exe -m pip install selenium
, - Now you have
selenium
module installed, you can check in your<path to Portable Python>\App\Python\Lib\site-packages
that you have nowselenium
and its dependencies.

- 402
- 6
- 14