Run Python script in custom Python folder

I have a problem running a python script on a system that doesn't have Python installed. I know what you are thinking ... but listen to me.

Some applications like C4D and Maya have their own Python versions. Unfortunately, they often compile them incorrectly, so modules that have to import their version of Python (like 2.6 for C4D) don't work at all. I don't know why they are doing this, I asked, but it seems due to lack of knowledge on their part.

To use a module that won't be imported, you must use a separate python installation. But I don't want to force users to install python, so I include my own python folder (2.7.6) with the modules I want to use inside, and run my script inside my custom (not installed) python folder, like this:

cmd = [my_python_path, "-E", my_script.py]
p = subprocess.Popen(cmd, shell=False, bufsize=...etc.

      

This works fine as long as Python 2.7.6 is actually installed on the system, but if not installed then it doesn't work. My system above is not targeting or using python installed. In fact, I moved the installed Python folder and renamed it to make sure it wasn't being used in some way and my script is working fine. So I know it is running against my python folder.

Question 1: Why doesn't python.exe run inside my user folder if there is no installed version of python installed? Is it because of some path variable?

Question 2: How can I get python.exe to work on systems, both Mac and Win, without officially installing Python?

thank

+3


source to share


1 answer


Just running Python.exe from a custom folder does not specify the specific location of many files and folders. These things are captured in Windows as system variables.

If you are copying the whole python folder, why not install python? Will it take the same place? Or if you really don't want to create executables: -



  • Py2Exe for windows!
  • py2app from Mac!
  • Pyinstaller for

I prefer py2exe.

0


source







All Articles