3
$\begingroup$

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?

$\endgroup$
1
  • $\begingroup$ You need to look at using third party modules with blender as it uses its own copy of python. It is also possible to set sys.path so that blender can find your system modules. $\endgroup$
    – sambler
    Oct 27, 2018 at 23:36

2 Answers 2

3
$\begingroup$

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...

$\endgroup$
0
$\begingroup$

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

$\endgroup$

This site is temporarily in read-only mode and not accepting new answers.

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