aws-deadline / deadline-cloud-for-cinema-4d

AWS Deadline Cloud for Cinema 4D
Apache License 2.0
6 stars 8 forks source link

Bug: Adaptor is unable to find win32file #40

Closed yuanmich2 closed 3 months ago

yuanmich2 commented 4 months ago

Expected Behaviour

I install pywin32 and expect the adaptor to be able to render.

Current Behaviour

It fails with this error:

2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: Traceback (most recent call last):
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: (null)  File "C:\Program Files\Python310\lib\site-packages\deadline\cinema4d_adaptor\Cinema4DClient\plugin\DeadlineCloudClient.pyp", line 49, in <module>
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT:     from deadline.cinema4d_adaptor.Cinema4DClient.cinema4d_client import main
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: (null)  File "C:\Program Files\Python310\Lib\site-packages\deadline\cinema4d_adaptor\Cinema4DClient\__init__.py", line 3, in <module>
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT:     from .cinema4d_client import Cinema4DClient
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: (null)  File "C:\Program Files\Python310\Lib\site-packages\deadline\cinema4d_adaptor\Cinema4DClient\cinema4d_client.py", line 14, in <module>
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT:     from openjd.adaptor_runtime_client import (
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: (null)  File "C:\Program Files\Python310\Lib\site-packages\openjd\adaptor_runtime_client\__init__.py", line 19, in <module>
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT:     from .win_client_interface import WinClientInterface as ClientInterface  # type: ignore
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: (null)  File "C:\Program Files\Python310\Lib\site-packages\openjd\adaptor_runtime_client\win_client_interface.py", line 12, in <module>
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT:     from .named_pipe.named_pipe_helper import NamedPipeHelper
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: (null)  File "C:\Program Files\Python310\Lib\site-packages\openjd\adaptor_runtime_client\named_pipe\named_pipe_helper.py", line 7, in <module>
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT:     import win32file
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: (null)ModuleNotFoundError: No module named 'win32file'
2024/05/10 14:51:07-07:00 ADAPTOR_OUTPUT: STDOUT: (null)Traceback (most recent call last):
2024/05/10 14:51:07-07:00 ADAPTOR_OUTPUT: STDOUT:   File "C:\Program Files\Python310\lib\site-packages\deadline\cinema4d_adaptor\Cinema4DClient\plugin\DeadlineCloudClient.pyp", line 65, in PluginMessage
2024/05/10 14:51:07-07:00 ADAPTOR_OUTPUT: STDOUT:     return parse_argv(sys.argv)
2024/05/10 14:51:07-07:00 ADAPTOR_OUTPUT: STDOUT:   File "C:\Program Files\Python310\lib\site-packages\deadline\cinema4d_adaptor\Cinema4DClient\plugin\DeadlineCloudClient.pyp", line 58, in parse_argv
2024/05/10 14:51:07-07:00 ADAPTOR_OUTPUT: STDOUT:     main()
2024/05/10 14:51:07-07:00 ADAPTOR_OUTPUT: STDOUT: NameError: name 'main' is not defined. Did you mean: 'min'?
2024/05/10 14:51:09-07:00 openjd_fail: Error encountered while starting adaptor: Cinema4D encountered an error and was not able to complete initialization actions.
2024/05/10 14:51:09-07:00 ERROR: Entrypoint failed: openjd_fail: Error encountered while starting adaptor: Cinema4D encountered an error and was not able to complete initialization actions.

Reproduction Steps

I installed python3.10 and C4D 2023 onto a Windows 2019 EC2 instance. I then installed all the python modules and submit a job.

I double-checked that I installed pywin32 and even made sure that both python3.10 and C4D's internal python interpreter could see the module:

image

I edited also edited the DeadlineCloudClient.pyp file to add the following lines:

print('new system paths:')
for n in sys.path:
    print(n)

import openjd

print("gonna try to import win32file")

try:
    import win32file
    print("we succeeded")
except Exception as e:
    print("we failed")
    print(e)
    traceback.print_exc()

these lines produced the following output:

2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: new system paths:
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: C:\Program Files\Maxon Cinema 4D 2023\resource\modules\python\libs\python310
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: C:\Users\deadline-worker\AppData\Roaming\Maxon\Maxon Cinema 4D 2023_BCDB4759_x\python310
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: C:\Program Files\Maxon Cinema 4D 2023\resource\modules\python\libs\python310.win64.framework\lib
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: C:\Program Files\Maxon Cinema 4D 2023\resource\modules\python\libs\python310.win64.framework\dlls
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: C:\ProgramData\Amazon\OpenJD\session-114161cdcba04aca88d4abf67ced0e98gkcjcgbr
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: C:\Users\deadline-worker\AppData\Roaming\Maxon\python\python310\libs
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: C:\Users\deadline-worker\AppData\Roaming\Maxon\Maxon Cinema 4D 2023_BCDB4759_x\python310\libs
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: C:\Program Files\Maxon Cinema 4D 2023\resource\modules\python\libs\python310.win64.framework\lib\site-packages
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: C:\Program Files\Python310\Lib\site-packages

2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: gonna try to import win32file
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: we failed
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: No module named 'win32file'
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: Traceback (most recent call last):
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: (null)  File "C:\Program Files\Python310\lib\site-packages\deadline\cinema4d_adaptor\Cinema4DClient\plugin\DeadlineCloudClient.pyp", line 41, in <module>
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT:     import win32file
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: (null)ModuleNotFoundError: No module named 'win32file'
2024/05/10 14:51:06-07:00 ADAPTOR_OUTPUT: STDOUT: (null)No module named 'win32file'

which shows that we were able to modify the system path to include the openjd module, but for some reason win32file can't be located even though it was installed to the same place as openjd.

I also tried installing pywin32 to a number of the other directories that show up in the system paths, but I am still getting the error.

Code Snippet

n/a

jericht commented 4 months ago

Hi, thanks for reporting this.

@yuanmich2 Do you remember which path the pywin32 modules were installed to? If it doesn't match one of the system paths printed in the above output, that would explain it, but if it does, then we'll need to take a deeper look

yuanmich2 commented 4 months ago

Hey @jericht,

Thanks for looking into this.

I installed pywin32 in a number of different places, but it didn't seem to make a difference. At the very end of my initial post I mentioned this.

I initially installed pywin32 in the same spot as where openjd was because the openjd import was working. This was the default folder that the pip install command chooses. I then went through the list of system paths from the logs and installed pywin32 to a random selection of those through pip install -t path/to/folder

I even went as far as to install pip on c4dpy.exe and used that pip to install to wherever that python binary gets its modules.

epmog commented 3 months ago

This is solved by installing pywin32 into Cinema4D's python, rather than c4dpy.exe.

I'll include these instructions in the DEVELOPMENT.md in an upcoming change