Rishi
Rishi

Reputation: 3578

multi platform portable python

I want to install python on a flash drive in a virtual environment so that I can develop code wherever I am. Is this possible to do in such a way that I can use my flash drive on windows/mac/linux computers?

Upvotes: 5

Views: 2745

Answers (3)

Perica Zivkovic
Perica Zivkovic

Reputation: 2630

  • For windows, head to Portable Python (http://PortablePython.com) to see various options you have,
  • For linux and Mac you don't need to install it on USB drive as those systems usually come with Python pre-installed. If you need specific packages for those systems, bring them on USB together with a command line script that can load them with one call in virtualenv on those systems and you are good to go !

Be aware that this is never 100% bullet proof as you are depending on Python version you are using/bringing packages for.

Upvotes: 4

naitsirhc
naitsirhc

Reputation: 5804

As @millimoose pointed out, you could install three different versions of Python.

For each Python package you are working on, you can create a .pth file in the site-packages directory of each Python version that you would like to use the package from.

Note that, as described here:

If you put a .pth file in the site-packages directory containing a path, python searches this path for imports.

For example, if you have a package named my_package that you are working on that resides at the path C:\Users\Me\Documents\dev_packages\my_package, you can add a file with extension .pth (note that the name doesn't matter, specifically it doesn't have to have any relation to the package name), with the contents:

C:\Users\Me\Documents\dev_packages

This will add C:\Users\Me\Documents\dev_packages to the Python import search-path, causing the my_package package to be discovered. By placing this .pth file in the site-packages directory of each Python version, my_package will be available in all corresponding versions of Python.

Upvotes: 0

Raz
Raz

Reputation: 605

You could try looking at setting up something using some VirtualEnv type environments, with the various Python versions installed on your machines.

Not sure how you'd get round the different paths on the different operating systems though.

Virtualenv: http://pypi.python.org/pypi/virtualenv

Upvotes: 0

Related Questions