It was most likely because the environment you were launching your
subprocess within was bootstrapped to Maya, and the PATH and supporting
PYTHON env keys were still going to have you pick up Maya's python. Not the
system python. Using the full path to the desired interpreter is one way
around it. Setting PATH is probably another.

On Mon, 6 Jul 2015 11:58 PM Benjam901 <[email protected]> wrote:

> Edit: SOLVED
>
> So I managed to solve it just after I published this post. For anyone
> needing a solution like this here is how I did it
>
> I set the python command in the bat file to point directly to which python
> version I wanted to run and hey presto it works :)
>
> set PYTHONVERSION=C:\Anaconda\python.exe
>
> set FILEPATH=%1
> set ARG=%2
>
> %PYTHONVERSION% "%UNITMANAGERPATH%\scripts\__main__.py" %FILEPATH% %ARG%
>
> Cheers,
>
> Ben
>
> On Monday, 6 July 2015 13:43:02 UTC+2, Benjam901 wrote:
>>
>> Hello all,
>>
>> So I am slightly stumped as to what is happening with my batch file.
>>
>> I am running an export process from Maya that executes a batch file using
>> subprocess. Inside the batch file is an execution to another python script
>> that error checks the Maya export.
>>
>> Running the batch using cmd  is great and works as expected.....however
>> when I try to do this inside of the Maya script it throws an lxml error
>> because of the python it is using.
>>
>> I checked the python exe that it is using and it is using *C:\Program
>> Files\Autodesk\Maya2015\bin\python.exe* which is strange because running 
>> *python
>> 'myscript.py' *in the batch file should run using the machines python
>> version.
>>
>> *The reason for running it through a .bat file is because I need it to be
>> run as a standalone application as well as an under the hood checker.*
>>
>>
>> *Here is what my bat file looks like for the most part:*
>> set
>> PYTHONPATH=C:\Anaconda\Lib\site-packages;%UNITMANAGERPATH%\scripts;%UNITMANAGERPATH%\UI;
>>
>> set FILEPATH=%1
>> set ARG=%2
>>
>> python "%UNITMANAGERPATH%\scripts\__main__.py" %FILEPATH% %ARG%
>>
>> *And the execution line inside my maya python script:*
>>
>> def debugUnit(unitPath=''):
>>      import subprocess
>>      unitDebuggerBat = os.getenv('MAYATOOLSPATH')+'\\cmd\\unit_debugger.bat'
>>
>>      return subprocess.check_output([unitDebuggerBat, unitPath, 
>> 'False']).split('UNITERROR')[-1].strip()
>>
>>
>> *Just incase the description was confusing here is the process:*
>>
>> *Export from Maya > Run .bat file from the export script > run python
>> error check script from .bat file*
>>
>> From what I am aware of running *python
>> "%UNITMANAGERPATH%\scripts\__main__.py" %FILEPATH% %ARG% *should run
>> using my machines Python which is Anaconda but it is using Maya's python
>> which is very confusing.
>>
>> Is there an additional command that I need to run in the .bat file to
>> make it completely separate from Maya's python exe?
>>
>> Any help would be much appreciated as always :)
>>
>> Cheers!
>>
>> Ben
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/d692c3ab-7373-42f0-ae18-e02d140d3f47%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/d692c3ab-7373-42f0-ae18-e02d140d3f47%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3QMc1joH64s1D0q9TDtrCGDB10P52-BO2fCYUJnxSsgg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to