Starting python script from other python

Heya

So I’m trying to run a python script from other python IDE. So for exampel

I have software with python 2.5.5
From that I want to start my standalone python engine 2.7.5 (C:/Python27) and then run script.

Can I do it? I tried all day today and no luck so far :frowning: Here you can see some more information I posted (env - Run python script from python using different python - Stack Overflow)

Initially I just want to be python 2.5.5>Python2.7.5 start>Run c:/test.py

Finnaly I want to
Python 2.5.5 Create arrays and objects > Send to Python2.7.5 > Run c:/test.py with arrrays and items from Python2.5.5.
I probably wont be able to do it so I will probably use pickle module or a txt file to HDD with information I want to cover. I guess that will be the way to transfer data.

Unless some1 could hint me how to do it. But I mainly want to run my script from other python…

Thanks, bye.

Something like this?

import subprocess
subprocess.Popen( r'C:\Python27\python.exe "C:	est.py"' )

Look into optparse to pass command line arguments as well with what Adam mentioned.

Hey Guys!

Thanks for fast reply :slight_smile:

The code dont work I’m getting error:

Import Error : no module named site

so I run import site

but then it crashes on Encodings.

This is the script I run :

import sys
import site
sys.path.append(“C:\Python27\Lib\encodings”)
sys.path.append(“C:\Python27\Lib”)
import encodings
import subprocess

  File "<string>", line 2, in <module>
  File "C:\Program Files\App\lib\python\site.py", line 415, in <module>
    main()
  File "C:\Program Files\App\lib\python\site.py", line 406, in main
    aliasmbcs()
  File "C:\Program Files\App\lib\python\site.py", line 356, in aliasmbcs
    import locale, codecs
  File "C:\Program Files\App\lib\python\locale.py", line 14, in <module>
    import sys, encodings, encodings.aliases
ImportError: No module named encodings

can you paste the entire script? You shouldn’t have to append the python dirs to your path unless your path is empty for some odd reason

Heya

I have something like this


import sys
import site
sys.path.append("C:\Python27\Lib\encodings")
sys.path.append("C:\Python27\Lib")
import encodings
import subprocess
subprocess.Popen( r'C:\Python27\python.exe "C:\RunPS.py"' )

and RunPS.py has

import comptypes
import os

import comtypes.client
import os
import re

ps = comtypes.client.CreateObject("Photoshop.Application")
ct = comtypes.client

and a lot more of my actions I need :slight_smile:

I’m trying to start PS after render finish and stitch all images the render rendered and so on. Now the stitching and so on is all coded and done. I just cant figure out how to execute script with possibly custom variables if no I’ll pickle them.

As far as I can tell my python 2.5.5 is very basic and stript out of any modules and so on - or most of them. I have to hand import a lot of things to get it to work :frowning:

ok some questions:

  • If you’re using python 2.5.5, why are you adding C:\Python27 to your path?
  • Why is your python 2.5.5 so stripped down?
  • Open python and enter this and paste in the results:
import sys
import pprint

pprint.pprint(sys.path)

Just replace any sensitive paths with * or something

Honestly you shouldn’t have to import anything but subprocess, something fishy is going on

Heya

I’m not sure why my python is so stripped down. Its the way they implemented it.

['C:\\Program Files\\App\\lib\\python\\site-packages\\PIL',
 'C:\\Program Files\\App\\examples\\presentations',
 'C:\\Program Files\\App\\lib\\python',
 'C:\\Program Files\\App\\lib\\python\\WIN64',
 'C:\\Program Files\\App\\bin\\WIN64\\python25v.zip',
 'C:\\Program Files\\App\\lib\\python\\DLLs',
 'C:\\Program Files\\App\\lib\\python\\lib',
 'C:\\Program Files\\App\\lib\\python\\lib\\plat-win',
 'C:\\Program Files\\App\\lib\\python\\lib\\lib-tk',
 'C:\\Program Files\\App\\bin\\WIN64']

And the problem is once I go to App\lib\python - there is no dlls, lib,plat-win,lib-tk,site-packages folders. Nothing. There is just python>python files and one folder which looks unrelated to python. I can zip it up and post it here.

Thanks again for your help!!

So guys any idea how to deal with it?

Im thinking now if I can get python 2.5.5 and then get PyQt4 for it + comtypes for PS but I cant find Qt for it so ehh :frowning: