3

I'm working on a script that processes some data coming from a web application running on a phone. The web application, written in javascript, sends data to the "blender python server" using websockets.

The code doesn't compile with the error:

ImportError: No module named 'websockets'

But that's not true, I have websockets installed, using pip, on my machine. And I've already used them with no problems. Is it possible that the blender environment prevents me to use them? Did anyone ever have any problems with some modules installed using pip?

Rage
  • 158
  • 2
  • 14

2 Answers2

3

You need to have the modules youre planning to use, on the python path where blender looks for the modules. blender comes with its own python installed. browse the blender directory youll find it. This is probably the cacuse. just copy your python/lib/sitepackages folder on it and I think youll have it done...

Javier
  • 196
  • 1
  • 4
0

The solution, as suggested by @Javier is to install the python modules inside the python blender folder.

On my Mac machine, the python module folder is located at:

/Applications/Blender/blender.app/Contents/Resources/2.79/python/lib/python3.5

Hence, we can install a new python module running a pip command:

pip install -t <direct directory> <package>

Update for Blender 2.8:

Blender 2.8 simplifies the installation of external packages, coming with pip already installed. To install an external package go to python's bin folder and run:

./python3.7m -m ensurepip (Just the first time)

./python3.7m -m pip install package

Rage
  • 158
  • 2
  • 14