本文介绍了无法在Maya 2014中导入Tkinter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Windows 7和Autodesk Maya2014.当我尝试导入Tkinter时遇到错误.请告诉我如何解决以下错误?如何在Autodesk Maya 2014中安装任何python软件包?

import Tkinter

错误

解决方案

我在Maya中添加了一些Python模块,并在最后解释了"addsitedir-trick",但并不是每个Python模块都能与Maya很好地玩. >

Windows上的Python是使用Visual Studio 2008 Professional构建的. Maya使用它自己的Python解释器,但是Autodesk使用另一个Visual Studio版本构建Maya.如果您安装了python模块并尝试将它们与Maya一起使用,则可能导致问题.精彩地在这里进行了说明(连同您自己编译所需模块的硬性解决方案):

http://p-nand-q .com/python/building-python-27-with-vs2010.html

可以尝试的方法:在Windows-box上安装Python 2.7,然后在Maya中安装要访问的模块(例如,使用pip).现在,在Maya中,将系统SitePackages(您刚刚在其中安装模块的位置)添加到Maya-Python-Interpreter SitePackages中,如下所示:

import site
site.addsitedir("/path/to/your/python27/Lib/site-packages")

甚至更干净的解决方案是使用virtualenv而不是全局site-packages文件夹! (至少这是我为获得psycopg2并要求与Maya一起玩而做的事情)

但是,正如在此答案开头提到的那样,这可能会失败(带有奇怪的错误).

顺便说一句:我强烈建议您使用pyside而不是Tkinter来制作Maya中的GUI.或Maya-Wrappers最好通过pymel. ( http://help.autodesk.com /cloudhelp/2017/ENU/Maya-Tech-Docs/PyMel/ui.html )

I am using windows 7 and Autodesk Maya 2014.When i am trying to import Tkinter i am getting error.please tell me how to solve error given below ?How to install any python package in Auto desk Maya 2014 ?

import Tkinter

Error

解决方案

I added a few Python modules to Maya with the "addsitedir-trick" explained at the end but not every python module will be playing nicely with Maya.

Python on Windows is built with Visual Studio 2008 Professional. Maya uses it's own Python interpreter but Autodesk builts Maya with another Visual Studio version. This can lead to problems if you insall python modules and try to use them with Maya. Beatuifully explained here (together with a the hard solution of compiling the wanted modules yourself):

http://p-nand-q.com/python/building-python-27-with-vs2010.html

What you can try: Install Python 2.7 on your Windows-box, install the module you want to access in Maya (eg with pip). Now in Maya add your system SitePackages (where you just installed the module to) to your Maya-Python-Interpreter SitePackages like so:

import site
site.addsitedir("/path/to/your/python27/Lib/site-packages")

Even cleaner solution would be to use a virtualenv instead of the global site-packages folder! (That's at least what i have done to get psycopg2 and requests play with Maya)

But as mentioned in the beginning of this answer there is a possibility that this may fail (with strange errors).

By the way: I highly recommend to use pyside instead of Tkinter if you want to do GUI stuff in Maya. Or the Maya-Wrappers preferably via pymel. (http://help.autodesk.com/cloudhelp/2017/ENU/Maya-Tech-Docs/PyMel/ui.html)

这篇关于无法在Maya 2014中导入Tkinter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 21:53