python - 为什么即使安装了 FBX 模块也找不到?
问题描述
注意*我从互联网上得到了这个代码
我正在尝试运行 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。
推荐阅读
- r - 使格子图中的某些线条不可见
- paypal - Paypal Sandbox Orders API - 捕获后资金未添加到余额中
- emacs - “选择已删除缓冲区”的“org-agenda-get-day-entries”错误
- html - 使用 Safari 在输入焦点上不需要的自动滚动到顶部
- javascript - 比较日期字符串
- javascript - C#多维数组只打印第一个元素
- c - 将函数传递给函数时,需要作为一元“&”操作数的错误左值
- wordpress - Htaccess 重定向到不同的文件夹
- javascript - 无法在 setTimeOut 中获取 conversationState 属性值
- spring - 在 jboss 7.1 AP 中运行时将项目转换为 spring5 和休眠 5.2.17 时出现异常