from within Blender (2.49b), when I try to run a Python script containing the line: "from os import urandom"
I get the error: "ImportError: cannot import name urandom"
My setup:
Ubuntu 12.04 LTS, 64-bit version
Blender 2.49b (blender-2.49b-linux-glibc236-py26-x86_64)
Python2.6.8
from within stand-alone python the same command ("from os import urandom") works fine, but not from within Blender's python.
I've searched around for hours and have not found a solution.
By the way, I am running the older Blender version because I am trying to use it with MBDyn and this requires the older Blender.
Any suggestions would be greatly appreciated.
cannot import name urandom
Moderators: jesterKing, stiv
Thanks for the quick reply.CoDEmanX wrote:are there two different python installations maybe? One with that module, and another without?
There are several versions of python on my machine, yes, and they all have the os module since it is a built-in.
I don't think that's the problem, though, because Blender is able to find the correct Python ("Compiled with PYthon version 2.6.2. Checking for installed Python... got it!"). Also, "import os" from within Blender works.
if "import os" works, can't you do
?
Code: Select all
import os
os.urandom(#)
I'm sitting, waiting, wishing, building Blender in superstition...
Nope, that doesn't work either. I get "AttributeError: 'module' object has no attribute 'urandom'CoDEmanX wrote:if "import os" works, can't you do
?Code: Select all
import os os.urandom(#)
Incidentally, if I run the following in Blender
import os
import inspect
print inspect.getfile(os)
I get /usr/lib/python2.6/os.pyc
which is also what I get when running the same code from Python in a terminal (outside Blender). So it looks like they are calling the same os.pyc code, yet in one case it can find urandom and in the other it can't. Strange.
It appears to be an OS-related problem, here's a possible fix:
https://gist.github.com/PureForm/5340738
Maybe this helps to test if urandom exists:
https://gist.github.com/PureForm/5340738
Maybe this helps to test if urandom exists:
Code: Select all
os_module = __import__("os")
print(hasattr(os_module, "urandom"))
I'm sitting, waiting, wishing, building Blender in superstition...