ImportError when running terminal command in maya standalone

46 views
Skip to first unread message

likage

unread,
May 15, 2017, 8:44:08 PM5/15/17
to Python Programming for Autodesk Maya
Hi everyone, I am trying to run a terminal command while using maya.standalone and run into some problems.
There is this terminal command in which if I run `someCommand my_file.txt`, it works correctly, as I expecting it to be.

When I tried to incorporate it into my script:
os.system('someCommand /user_data/some_file.txt')


I was prompted with the following error when I tried to execute it with Mayapy command:

Traceback (most recent call last):
 
File "/server/scripts/someCommand", line 6, in <module>
   
import os
ImportError: No module named os


Tried using `subprocess` but same error persists. How can I rectify this and why is it that `os` module error occurs?
In my python file, `os` is working for sure..



Justin Israel

unread,
May 15, 2017, 9:44:15 PM5/15/17
to Python Programming for Autodesk Maya
So if you have a script that does nothing except "maya.standalone.initialize()"  and "import os", you are seeing this import error?
Are you doing anything to modify the PYTHONPATH?

Justin


--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/97fa1bf8-0ada-4f1f-a6c2-f1e72b8940c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alok Gandhi

unread,
May 16, 2017, 7:22:58 AM5/16/17
to python_in...@googlegroups.com
Also, this does not solve your problem but is relevant, just so you know, import pymel.core will take care of the initialization in one line, you read more about it here. But if you want to be more explicit about it (which I think you should be) then your initialization code is better.

On Tue, May 16, 2017 at 9:44 AM, Justin Israel <justin...@gmail.com> wrote:
So if you have a script that does nothing except "maya.standalone.initialize()"  and "import os", you are seeing this import error?
Are you doing anything to modify the PYTHONPATH?

Justin

On Tue, May 16, 2017 at 12:44 PM likage <dissid...@gmail.com> wrote:
Hi everyone, I am trying to run a terminal command while using maya.standalone and run into some problems.
There is this terminal command in which if I run `someCommand my_file.txt`, it works correctly, as I expecting it to be.

When I tried to incorporate it into my script:
os.system('someCommand /user_data/some_file.txt')


I was prompted with the following error when I tried to execute it with Mayapy command:

Traceback (most recent call last):
 
File "/server/scripts/someCommand", line 6, in <module>
   
import os
ImportError: No module named os


Tried using `subprocess` but same error persists. How can I rectify this and why is it that `os` module error occurs?
In my python file, `os` is working for sure..



--
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 python_inside_maya+unsub...@googlegroups.com.

--
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0QBiLWZE9Pc0OWr0mOKTzumHvkimgR0kXHm%3DJhWHoiOA%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages