简体   繁体   中英

Is there an alternative to adding Python to PATH

I have a few questions mostly; some about the PATH variable and some about distributing modules.

  • Is it possible to distribute a Python interpreter with my code that only includes the modules needed to run the program?

  • Is it possible to create my own distribution of python that just has the modules i need installed?

  • Is it possible to get the location of the Python installation without using the PATH variable to launch Python (on Windows)?

  • Why doesn't the installer for Python include an option to add Python to the PATH ?

The reason I ask these things is because I was thinking about how I could share a script with someone without them having to manually add Python to the PATH , and so I could distribute the modules needed for the program without having to freeze my script.

Python applications can be wrapper self-contained installations.

One suggested way to do this on Microsoft Windows is py2exe http://www.py2exe.org/

py2exe should be able to handle module dependencies so that you distribute only Python packages (eggs) needed for the application. I am not sure how it can trim down the Python distribution itself.

This is the suggested method if the target machine does not contain Python interpreter or it is too difficult to install for the end user.

The default Python location is also written to Windows registry if you need to poke it for some reason http://opensourcehacker.com/2011/02/22/changing-the-active-python-interpreter-on-windows/ (diclaimer: my blog)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM