本文介绍了Maya的python模块的Eclipse环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置Eclipse IDE,以识别 maya.cmds 模块,这是与 maya 模块相关联的所有模块。以下代码是在Eclipse中运行的测试以及Maya的脚本编辑器。

I'm trying to set up the Eclipse IDE to recognize the maya.cmds module, an all modules associated with the maya module. The following code are tests run in Eclipse, and Maya's script editor.

import maya
print 'maya:\n', dir(maya)

from maya import cmds
print 'cmds:\n', len(dir(cmds)) # too many to print

print 'sphere: ', cmds.sphere

在Maya的脚本编辑器中, p>

In Maya's script editor the code results in

maya:
['OpenMaya', '_OpenMaya', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 'app', 'cmds', 'mel', 'standalone', 'stringTable', 'utils']

cmds:
3190

sphere: <built-in method sphere of module object at 0x0000000019F0EEE8>

在Eclipse中,代码导致

In Eclipse the code results in

maya:
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__']

cmds:
6

sphere: 
Traceback (most recent call last):
AttributeError: 'module' object has no attribute 'sphere'

我已经做了大量的搜索,在谷歌组蟒蛇里面的玛雅和网页搜索。我发现的最好的是以下链接,但是这根本没有解决我的问题,最终给出了相同的结果。

I've done a lot of searching, on the google group "python inside maya", and web searches. The best I've found was the following link, however this did not solve my issue at all, and in the end gave the same result. http://www.luma-pictures.com/tools/pymel/docs/1.0/eclipse.html

我已经看到我应该在Eclipse中设置我的环境路径,而不是我的机器, ve也读了相反的意见。我应该设置什么环境变量,在Eclipse,Windows或其他位置,以及在Eclipse,Windows或两者中?

I've read that I should be setting my environment paths in Eclipse, rather than my machine, and I've also read the opposite opinion. What environment vars should I set, to where, and in Eclipse, Windows, or both?

推荐答案

解决方案是导入maya独立并初始化它。
这可以让您访问其中的maya包和模块。

The solution is to import maya.standalone and initialize it.This gives you access to the maya packages and modules therein.

import maya.standalone
maya.standalone.initialize()

import maya
print 'maya:\n', dir(maya)

from maya import cmds
print 'cmds:\n', len(dir(cmds)) # too many to print

print 'sphere: ', cmds.sphere

输出:

maya:
['__builtins__', '__doc__', '__file__', '__name__', '__package__', 
'__path__', 'app', 'cmds', 'mel', 'standalone', 'stringTable', 'test', 'utils']

cmds:
2945

sphere:  <built-in method sphere of module object at 0xf33948>

这篇关于Maya的python模块的Eclipse环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 05:34