EpicGames / MetaHuman-DNA-Calibration

https://epicgames.github.io/MetaHuman-DNA-Calibration/
Other
452 stars 117 forks source link

ImportError of DNAViewer #4

Closed Clairezsh closed 1 year ago

Clairezsh commented 1 year ago

I tried to execute the code in "dna_viewer_demo" in maya2022, it reports an error: ImportError: file D:/DNA-Calibration-pc\dna_viewer\reader\behavior.py line 5: cannot import name 'BinaryStreamReader' from 'dna' (C:/Users/xxx/Documents/Megascans Library/support/plugins/maya/7.0/MSLiveLink/DHI/lib/Windows/python3\dna.py) which seems import dna module from wrong position. I've checked the syspath, the folder of "ROOT_DIR/lib/window" is in the front. And I also tried other method to set the import root, but still doesn't work. Is there any good solution? Thank you so much!

smilicev commented 1 year ago

Hi @Clairezsh, thanks for filling an issue. As you said there is issue with your PATH environment variable. dna_viewer_demo.py should fix that problem, but for some reason it cannot. Can you get output of this command echo %PATH%?

Clairezsh commented 1 year ago

I use "print(syspath)" in maya and the output was like this: ['{ROOT_DIR}/data', '{ROOT_DIR}/examples', '{ROOT_LIB_DIR}/windows', 'D:/DNA-Calibration-pc', 'C:\\Program Files\\Autodesk\\Maya2022', 'C:\\Program Files\\Autodesk\\Maya2022\\plug-ins\\ATF\\scripts', 'C:\\Program Files\\Autodesk\\Bifrost\\Maya2022\\2.3.1.0\\bifrost\\scripts', 'C:\\Program Files\\Autodesk\\Maya2022\\plug-ins\\MASH\\scripts', 'C:\\Program Files\\Autodesk\\MayaUSD\\Maya2022\\0.13.0\\mayausd\\MayaUSD3\\plugin\\adsk\\scripts', 'C:\\Users\\xxx\\Documents\\Megascans Library\\support\\plugins\\maya\\7.0\\MSLiveLink', 'C:\\Program Files\\Rokoko Motion Library\\Maya\\2022\\scripts', 'C:\\Program Files\\Autodesk\\Maya2022\\plug-ins\\fbx\\scripts', 'C:\\Program Files\\Autodesk\\Maya2022\\plug-ins\\camd\\scripts', 'C:\\Program Files\\Autodesk\\Arnold\\maya2022\\scripts', 'C:\\Program Files\\Allegorithmic\\Adobe Substance 3D for Maya\\2022\\scripts', 'C:\\Program Files\\Autodesk\\Maya2022\\plug-ins\\sweep\\scripts', 'C:\\Program Files\\Autodesk\\Bifrost\\Maya2022\\2.3.1.0\\vnn\\scripts', 'C:\\Program Files\\Autodesk\\Maya2022\\plug-ins\\xgen\\scripts', 'C:\\Program Files\\Autodesk\\Bifrost\\Maya2022\\2.3.1.0\\bifrost\\python\\site-packages', 'C:\\Program Files\\Autodesk\\MayaUSD\\Maya2022\\0.13.0\\mayausd\\MayaUSD3\\lib\\python', 'C:\\Program Files\\Autodesk\\MayaUSD\\Maya2022\\0.13.0\\mayausd\\USD3\\lib\\python', 'C:\\Program Files\\Autodesk\\Maya2022\\bin\\python37.zip', 'C:\\Program Files\\Autodesk\\Maya2022\\Python37\\DLLs', 'C:\\Program Files\\Autodesk\\Maya2022\\Python37\\lib', 'C:\\Program Files\\Autodesk\\Maya2022\\bin', 'C:\\Program Files\\Autodesk\\Maya2022\\Python37', 'C:\\Program Files\\Autodesk\\Maya2022\\Python37\\lib\\site-packages', 'C:\\Users\\xxx\\AppData\\Roaming\\Python\\Python37\\site-packages', 'C:\\Program Files\\Autodesk\\Maya2022\\bin\\python37.zip\\lib-tk', 'C:/Users/xxx/Documents/maya/2022/zh_CN/prefs/scripts', 'C:/Users/xxx/Documents/maya/2022/zh_CN/scripts', 'C:/Users/xxx/Documents/maya/scripts', '..', 'C:\\Users\\xxx\\Documents\\Megascans Library\\support\\plugins\\maya\\7.0\\MSLiveLink\\Megascans\\RequestLibrary', '..', 'C:\\Users\\xxx\\Documents\\Megascans Library\\support\\plugins\\maya\\7.0\\MSLiveLink\\DHI\\pose_wrangler', 'C:\\Users\\xxx\\Documents\\Megascans Library\\support\\plugins\\maya\\7.0\\MSLiveLink\\DHI', 'C:/Users/xxx/Documents/Megascans Library/support/plugins/maya/7.0/MSLiveLink/DHI/lib/Windows/python3', 'C:\\Program Files\\Autodesk\\Arnold\\maya2022\\extensions']

Clairezsh commented 1 year ago

I tried to specify the import path as lib/windows, it reports: ImportError: file D:/DNA-Calibration-pc/lib\windows\dna.py line 13: cannot import name '_py3dna' from 'lib' (C:\Users\xxx\Documents\Megascans Library\support\plugins\maya\7.0\MSLiveLink\DHI\lib\__init__.py) #

smilicev commented 1 year ago

I think problem is with your ROOT_DIR variable value in your script. This should be if you use mayapy interpreter in console application

ROOT_DIR = f"{ospath.dirname(ospath.abspath(__file__))}/..".replace("\\", "/")

But in your case, because you are using this example in Maya your line should be:

ROOT_DIR = r"c:\MetaHuman-DNA-Calibration".replace("\\", "/")

or simpler

ROOT_DIR = "c:/MetaHuman-DNA-Calibration"

If c:/MetaHuman-DNA-Calibration is location where you cloned this repo.

Here is documentation link.

Clairezsh commented 1 year ago

I have changed the ROOT_DIR: image also, in the behavier.py the dna path is: image but when I run that in maya, it reports that error. What's more, it seems like the working path is not true (in "C:\Users\xxx\Documents\Megascans Library..."):

I tried to specify the import path as lib/windows, it reports: ImportError: file D:/DNA-Calibration-pc/lib\windows\dna.py line 13: cannot import name '_py3dna' from 'lib' (C:\Users\xxx\Documents\Megascans Library\support\plugins\maya\7.0\MSLiveLink\DHI\lib\__init__.py) #

smilicev commented 1 year ago

Problem is with your variables, you have deleted f string, and then they are just plan text.

This is how they should look like.

OUTPUT_DIR = f"{ROOT_DIR}/output"
DATA_DIR = f"{ROOT_DIR}/data"
EXAMPLES_DIR = f"{ROOT_DIR}/examples"
ROOT_LIB_DIR = f"{ROOT_DIR}/lib"

Revert changes that you made in git, and you will be fine.

I will close this issue. If your problem persists, feel free to reopen this issue with additional details.

Clairezsh commented 1 year ago

That works, Thank you so much!