6

I have been in the hope of finding a way to use awesome Anaconda Python in Blender in Windows 7 x64, as I was inspired by several articles including the one described here on why using Anaconda is advantageous. I have tried many suggested potential solutions, as summarized below, but unfortunately no success:

  1. Calling 3rd Party Python Modules in Blender Scripts
  2. SpaceBlender
  3. Using 3rd party Python modules
  4. ImportError: DLL load failed: %1 is not a valid Win32 application. But the DLL's are there

I truly would love to be able to utilize Anaconda. I particularly want to be able to import many packages including h5py for reading HDF files, which are larger than 2GB. Because of the C library dependencies of h5py, it is impossible to build them in Windows from source. Could the community help me find a practical way of using Anaconda3-4.0.0-Windows-x86_64 in blender-2.77a-windows64? I don't mind completely replacing Blender python with Anaconda (although I copied them in blender folder and did not work).

shashashamti2008
  • 294
  • 4
  • 13

2 Answers2

4

I succeeded using the following solution:

  1. Install anaconda2 x64(I use python 2.7 usually, so I installed it.).
  2. Install Blender 2.77a x64.
  3. Create py35 environment for blender by command conda create --name py35 python=3.5 anaconda.
  4. Rename C:\Program Files\Blender Foundation\Blender\2.77\python to _python.
  5. (a) Copy & Paste the folder from C:\Anaconda2\envs\py35 to C:\Program Files\Blender Foundation\Blender\2.77\python.
  6. (b) Or, alternatively, create a link to the anaconda installation. This way any updates will automatically be available: You need to run cmd as administrator (use right click on the item)

    D:\Blender Foundation\Blender\2.77>mv python python_old
    D:\Blender Foundation\Blender\2.77>mklink /j python d:\Anaconda2\envs\py3
    Junction created for python <<===>> d:\Anaconda2\envs\py3
    
  7. Try import bpy, import pandas, import numpy, import scipy, import sklearn, ...etc. on Blender python console.

Console, Text Editor both worked fine for me.

ntg
  • 227
  • 1
  • 11
su79eu7k
  • 141
  • 5
  • Can you comment on how Blender can manage using python 2.7 as it needs python 3? Does creating conda create py35 python=3.5 anaconda actually creates python 3 or it is a virtual python 3? – shashashamti2008 May 02 '16 at 17:36
  • 1
    @Ahmad Blender don't care about python 2.7(Actual) or 3.5(Virtual) of my anaconda. It only cares about .../Blender/2.77/python... which is copied version of my virtual python 3.5 of anaconda in my case. – su79eu7k May 03 '16 at 00:50
  • 1
    conda create py35 python=3.5 anaconda will create a python 3 environment. you can use this to have multiple environments – ntg Nov 04 '16 at 15:14
  • you can switch between environments, E.g. open a command prompt (run cmd) and then type "activate py35" then typing python will run python 3 ... – ntg Nov 20 '17 at 10:02
2

Tried a modified method from the one provided by @ntg:

Created a virtual environment inside the blender folder to replace python folder it has. The following example is for macOS and blender 2.82.

conda create --prefix /Applications/Blender.app/Contents/Resources/2.82/python python=3.7

To install python packages I used this to activate the environment and install the packages.

conda activate /Applications/Blender.app/Contents/Resources/2.82/python
conda install pandas 
conda install geopandas