我似乎在这里做不当的事情,对它的内容感到震惊。我试图从Maya中启动The Foundry NUKE,当我尝试时,出现与找不到模块有关的错误。但是,如果我在常规命令行上加载Nuke,则可以完美加载。似乎与Maya的Python解释器有关的问题找不到此模块?我似乎找不到...

更新#1:我什至尝试对Nuke插件,DLL,lib和dirs进行一些sys.path.appends的操作,但这些操作都没有用...

更新#2:我已经重新安装了Python,并确认它是64位的。还检查了我的64位Maya和Nuke版本。我也尝试了以下方法...在Maya外打开一个普通的Python命令提示符,以通过os.system调用加载Nuke,并且它可以工作。只有在Maya中对Nuke进行os.system调用时,它会因导入此_socket模块的问题而失败。检查Maya正在加载的_socket模块时,我得到:

import _socket
print _socket.__file__
C:\Program Files\Autodesk\Maya2016\Python\DLLs\_socket.pyd


使我相信Maya的Python正在加载此_socket的diff版本,然后是Nuke是什么,那里出现了问题。

原始代码/错误:

C:\Program Files\Nuke9.0v8\Nuke9.0.exe
Traceback (most recent call last):
    File "C:/Program Files/Nuke9.0v8/plugins/init.py", line 22, in <module>
      import nukescripts.ViewerProcess
    File "C:/Program Files/Nuke9.0v8/plugins\nukescripts\__init__.py", line 22, in <module>
      from nukeprofiler import *
    File "C:/Program Files/Nuke9.0v8/plugins\nukescripts\nukeprofiler.py", line 2, in <module>
        import socket
    File "C:\Python27\lib\socket.py", line 47, in <module>
        import _socket
ImportError: DLL load failed: The specified module could not be found.
C:/Program Files/Nuke9.0v8/plugins/init.py : error interpreting this plugin




from PySide import QtCore, QtGui
import maya.cmds as cmds
import os, sys
#import subprocess


class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(314, 216)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(Dialog.sizePolicy().hasHeightForWidth())
        Dialog.setSizePolicy(sizePolicy)
        self.blastBtn = QtGui.QPushButton(Dialog)
        self.blastBtn.setGeometry(QtCore.QRect(110, 130, 75, 23))
        self.blastBtn.setObjectName("blastBtn")

        self.blastBtn.clicked.connect(self.RunPlayblast)

        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Playblast & Nuke Me", None, QtGui.QApplication.UnicodeUTF8))
        self.blastBtn.setText(QtGui.QApplication.translate("Dialog", "Blast", None, QtGui.QApplication.UnicodeUTF8))


    def RunPlayblast(self):
        cmds.playblast(fmt="qt", f="myMovie.mov", fo=True)
        self.RunNuke()

    def RunNuke(self):
        nukeExe = r'C:\Program Files\Nuke9.0v8\Nuke9.0.exe'
        myTemplate = r'B:\home\nukePBTemplate.nk'

        os.system('"'+nukeExe+'" -x ' +myTemplate)

        #command = nukeExe+" -x "+myTemplate
        #subprocess.Popen(command)

if __name__ == '__main__':
    app = QtGui.QApplication.instance()
    Dialog = QtGui.QDialog()
    blastMe = Ui_Dialog()
    blastMe.setupUi(Dialog)
    Dialog.show()
    app.exec_()

最佳答案

我认为您可以使用内置子进程来调用nuke

import subprocess
nukeProcess = subprocess.Popen(["C:/Program Files/Nuke9.0v8/Nuke9.0.exe", "-x", "B:/home/nukePBTemplate.nk"])


而且我认为您从未使用过mel.eval(“ system / whatever”),因为您尝试使用python时,python已经内置了许多内置方法来处理系统命令,例如子进程,命令等。

更新资料

import subprocess, os
newEnv = os.environ.copy()
newEnv["PYTHONPATH"] = newEnv["PATH"] + "/local/share/python/2.7/libs"
nukeProcess = subprocess.Popen(["C:/Program Files/Nuke9.0v8/Nke9.0.exe", "-x", "B:/home/nukePBTemplate.nk"], env=newEnv)

08-25 00:04