3
$\begingroup$

I'm having trouble importing the ctypes Python module from a 32-bit installation of Blender 2.73 on Windows. I need to use Blender's included Python, not the system Python. From the interactive console inside the Blender GUI with no project or anything loaded, I get the following error:

>>> import ctypes
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
  File "C:\Program Files (x86)\Blender Foundation\Blender\2.73\python\lib\ctypes\__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ImportError: DLL load failed: %1 is not a valid Win32 application.

My Windows installation is 64-bit but I figured that shouldn't matter given that I'm running Python from a 32-bit installation of Blender and ctypes is part of the initial installation.

I have a feeling that the issue is specific to Windows because I cannot reproduce the issue on 64-bit Ubuntu.

Any ideas?

$\endgroup$
4
  • $\begingroup$ try adding Blender's python to the %PATH% environment variable.it should be the first path so that blender doesn't use any other python you already have installed on your system. $\endgroup$
    – user2816
    Sep 10, 2015 at 18:16
  • $\begingroup$ @Houssem Thanks for the suggestion but I get the same error. I should note that I was getting this error even before I had installed a system Python for Windows at all, so I think the system Python interfering with Blender's Python is not likely the issue. $\endgroup$
    – Alex A.
    Sep 10, 2015 at 19:44
  • $\begingroup$ @zeffii This will be part of a larger, cross-platform project though, and it's been specified to run on 32-bit Blender, unfortunately. $\endgroup$
    – Alex A.
    Sep 10, 2015 at 20:17
  • $\begingroup$ @zeffii In general, 32-bit programs work fine on a 64-bit OS. I specifically installed the 32-bit version of Blender. I'm using Windows 7. $\endgroup$
    – Alex A.
    Sep 10, 2015 at 20:38

1 Answer 1

3
+50
$\begingroup$

This is a known bug in 2.73 and 2.73a:

https://developer.blender.org/T43961

Blender 2.74, 2.75 and 2.76 should work. adding the missing _ctypes python module (_ctypes.pyd) from these versions to 2.73 should also work.

$\endgroup$
1
  • $\begingroup$ I copied _ctypes.pyd from Blender 2.75a and simply replaced the existing file in 2.73a and it now works perfectly. Thanks so much for your help! $\endgroup$
    – Alex A.
    Sep 11, 2015 at 23:13

You must log in to answer this question.

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