繁体   English   中英

为什么即使安装了 FBX 模块也找不到?

[英]Why does it say FBX module not found even though it is installed?

注意*我从互联网上得到了这个代码

我正在尝试运行 python 脚本来验证 fbx 文件中的纹理尺寸。 我已经声明了一个可以使用的尺寸列表,如果使用的纹理尺寸不符合指定的尺寸,那么代码将返回错误。

但是当我尝试运行代码时,python 无法找到 FBX 模块。 它给了我这个错误:

Traceback (most recent call last):
  File "C:\Users\anirudh.b.SMARTAPT\Downloads\htm-fbx-introduction_to_the_python_fbx_sdk (2)\fbxTextureChecker-p1.py", line 1, in <module>
    import fbx
ModuleNotFoundError: No module named 'fbx'

我在互联网上查找了这个问题,并没有发现任何用处。 我使用 Python 3.7 并通过 pip 安装了所有必需的模块。 我通过安装程序安装了 FBX SDK 和 Python 绑定,并将必要的文件复制到 Python37\Lib\site-packages(尝试了 64x 和 86x 位文件)。

难道问题是由于我的 python 版本造成的。 我需要使用其他版本吗? 有没有办法让脚本在 Python3.7 本身中工作?

import fbx
import Image
import sys

filepath = r'C:\Autodesk\cubeMan.fbx'
validTextureDimensions = [ (256, 256), (512, 512) ]
manager = fbx.FbxManager.Create()
importer = fbx.FbxImporter.Create( manager, 'myImporter' )
status = importer.Initialize( filepath )

if status == False:
    print('FbxImporter initialization failed.')
    print('Error: %s' % importer.GetLastErrorString())
    sys.exit()

scene = fbx.FbxScene.Create( manager, 'myScene' )
importer.Import( scene )
importer.Destroy()
textureArray = fbx.FbxTextureArray()
scene.FillTextureArray( textureArray )
invalidTextures = {}

for i in range( 0, textureArray.GetCount() ):        
    texture = textureArray.GetAt( i )
    if texture.ClassId == fbx.FbxFileTexture.ClassId:
        textureFilename = texture.GetFileName()
        image = Image.open( textureFilename )
        width, height = image.size
        if (width, height) not in validTextureDimensions:
            invalidTextures[ textureFilename ] = (width, height)
            print('Invalid dimensions (%sx%s) - %s\n' % (width, height, textureFilename ))

我建议使用 python 2.7 而不是 3.7。 它适用于我的 2.7。

https://help.autodesk.com/view/FBX/2016/ENU/?guid=__files_GUID_2F3A42FA_4C19_42F2_BC4F_B9EC64EA16AA_htm

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM