multi platform portable python

旧街凉风 提交于 2019-12-01 18:19:35
  • 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.

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

naitsirhc

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!