0
$\begingroup$

I would like to use Blender 2.78c (64bit, from zip file) to perform rendering tasks on my IIS7 server running at a Win7 machine. The server uses ASP.NET and C# to create a new process which starts Blender in the command line and renders a predefined scene. Basically the process calls

C:\path-to-blender\blender.exe -b -noaudio file-with-a-python-script-to-render.blend -- some_input_arguments

Everything works fine while I am locally in the Debug mode using Visual Studio's internal IIS Express. I get nice renderings, no errors and no problems. However, once published and executed from the IIS the Blender fails to start. It crashes with the following stderr:

Fatal Python error: Py_Initialize: can't initialize sys standard streams OSError: [WinError 6] The handle is invalid Current thread 0x00002f78 (most recent call first):

It seems there is a problem initializing Python for Blender. Blender folder and its python subfolder are owned by the user account of the web worker, so that should be no problem. I am not sure if this is the right place to ask, but all my search on this topic failed yet. I only found this https://stackoverflow.com/questions/38725037/deploy-blender-to-azure-app which does not provide a good answer. I hope someone can help ...

$\endgroup$
6
  • $\begingroup$ I had just found a similar thing on *nix - it happens with 2.78 and 2.77 but not 2.76, this leads to looking like it is python 3.5 related. Try downloading 2.76 and see if you get the same error. $\endgroup$
    – sambler
    Commented Apr 22, 2017 at 2:47
  • $\begingroup$ I deleted my answer because now I'm not so sure what your problem may be. I was going to suggest that you need to actually launch blender through your system such as CMD. I'm not familiar with C# but with C++ you can run a system command easily. the reason being is because when you start a process of Blender.exe it ignores any arguments you try to pass. This is my personal experience. If that wasn't the issue, it might be a configuration with IIS. $\endgroup$ Commented Apr 22, 2017 at 4:15
  • $\begingroup$ @sambler I confirm it works with 2.76! Thank you for the hint. At least it is kind of a progress in resolving the issue. Unfortunately, it is not a good option for me since I would like to be able to use the latest Cycles features, not only those from 2015. $\endgroup$
    – Isolin
    Commented Apr 22, 2017 at 10:59
  • $\begingroup$ @Isolin Actually it does help point to being a bug report - worked with py3.4 and fails with py3.5. I was wondering if it was a recent minor update to python as I build blender using the latest release of python, but as your windows version will use the python from the official blender releases, it would appear to be a python 3.5 issue. $\endgroup$
    – sambler
    Commented Apr 22, 2017 at 17:20
  • $\begingroup$ @sambler I am working on the issue and I can report some progress. There was aboslutely no way to make it work with 3.5. I am currently trying to force blender to run with Python 3.6 and it seems that the issue is gone there. However, I am having problems with numpy throwing the from . import multiarray : ImportError DLL load failed. If you have a Blender build with 3.6 or you can instruct me how to achieve that by myself it would be a great help! $\endgroup$
    – Isolin
    Commented Apr 22, 2017 at 17:27

1 Answer 1

1
$\begingroup$

After 30 hours of trying, I am very happy that I made it work! Not sure whether this workaround is safe, but yet it works for Blender 2.78:

  1. Rename blender-dir\2.78\python to something else, e.g. blender-dir\2.78\python-old
  2. Download the embeddable zip of Python 3.5.3 from https://www.python.org/downloads/release/python-353/
  3. Unpack its content to blender-dir\2.78\python (a new directory using the same name)
  4. Unpack its blender-dir\2.78\python\Python35.zip to blender-dir\2.78\python\lib
  5. Copy contents of blender-dir\2.78\python-old\lib\site-packages to blender-dir\2.78\python\lib\site-packages except for __pycache__ directories
  6. I am not sure yet whether any other files or directories need to be copied from python-old\lib to python\lib, if yes I will update the answer.
  7. Find all __pycache__ directories in blender-dir\2.78\scripts\ and delete them
  8. Copy blender-dir\2.78\python\python35.dll to blender-dir replacing the old python35.dll

So the issue is resolved by pushing in Python 3.5.3. I hope Blender will bundle it in its next release. In the meanwhile, please let me know in a comment in case anyone else encounters a similar problem :)

$\endgroup$
2
  • $\begingroup$ Nice to see you found a fix. I'm sure I didn't have this issue until recently, I expect it may be specific to python 3.5.2. This is best reported as a bug, if nothing else so that 3.5.2 doesn't get used with the next release. $\endgroup$
    – sambler
    Commented Apr 23, 2017 at 3:16
  • $\begingroup$ I (finally) did. $\endgroup$
    – Isolin
    Commented May 4, 2017 at 14:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .