Skip to content

Commit 1d9bc60

Browse files
authored
Merge pull request #2 from NumesSanguis/v1.2.1
Resolve Windows issue not finding installed library in userspace
2 parents e8923ad + 73f1ddc commit 1d9bc60

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

README.md

+12-6
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@ Blender 2.8x add-on that allows streaming of data (from another computer) into B
33
**without** freezing the interface (publisher-subscriber pattern).
44

55
## Update
6+
- v1.2.1 (2022-11-13) - Fixed Python libraries (`pyzmq`) not findable when installed in userspace
7+
- On **Windows**, pip installed libraries might be installed outside the Blender dir.
8+
When failing to import a library, an extra import attempt adds `site.getusersitepackages()` to `sys.path`.
9+
- Blender on Windows might be installed under: `C:\Program Files\Blender Foundation\Blender 3.3\3.3\python\bin\python.EXE`.
10+
However, even when referring to this binary, libraries might still be installed under e.g.
11+
`C:\users\{user}\appdata\roaming\python\python310\site-packages`
612
- v1.2 (2022-11-01) - Now supports **Blender version 2.93 LTS and 3.3 LTS**! Changes:
713
- No Blender restart required anymore
814
- Python binary has to be accessed from `sys.executable` from v2.93 (rather than `bpy.app.binary_path_python`)
915
- Slightly refracted code in `PIPZMQ_OT_pip_pyzmq`
1016
- Blender < 2.93 functioning unchanged
1117
- Test scripts moved under `utils/`
12-
- v1.1 (2020-02-10)
13-
- **Blender 2.81+ pip support**: In Blender 2.81 pip is enabled by default.
14-
This update takes that behavior into account. If the `Enable pip & install pyzmq` button fails, it still executes
15-
`ensurepip.bootstrap()`. Restart Blender and try again, it will work this time
16-
(on Windows make sure you run with admin rights).
18+
- v1.1 (2020-02-10) - **Blender 2.81+ pip support**. Changes:
19+
- In Blender 2.81 pip is enabled by default. This update takes that behavior into account.
20+
- If the `Enable pip & install pyzmq` button fails, it still executes
21+
`ensurepip.bootstrap()`. Restart Blender and try again, it will work this time
22+
(on Windows make sure you run with admin rights).
1723

1824
## Overview
1925
Blender is very powerful software, but if you run your own code that's a bit heavy, you quickly make the interface
@@ -45,7 +51,7 @@ for programs outside Blender.
4551
1. Anaconda 3.10+: https://www.anaconda.com/distribution/
4652
2. `conda create --name bzmq python=3.10` # create environment with Python 3.7
4753
3. `conda activate bzmq` # activate newly created environment
48-
4. `conda install -c anaconda pyzmq=24.0` # install pyzmq in this environment
54+
4. `conda install -c conda-forge pyzmq=24.0` # install pyzmq in this environment
4955
- System Python: `pip install pyzmq=24.0.*`
5056

5157
## How to use

blendzmq_panel.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
# Copyright (c) Stef van der Struijk <stefstruijk@protonmail.ch>
2020

21+
import os
22+
import sys
23+
import site
2124
import bpy
2225
from bpy.types import Panel
2326

@@ -42,7 +45,15 @@ def draw(self, context):
4245
# check if pyzmq is installed; will fail with an ImportError if not
4346
# if installed, will show interaction options: (dis)connect socket and whether to use dynamic object selection
4447
try:
45-
import zmq
48+
# attempt 1: installed and on Python sys path
49+
try:
50+
import zmq
51+
# attempt 2: maybe installed, but not yet in sys path (Windows)
52+
except ImportError:
53+
user_site_packages = site.getusersitepackages()
54+
if os.path.exists(user_site_packages) and user_site_packages not in sys.path:
55+
sys.path.append(user_site_packages)
56+
import zmq
4657

4758
# connection information
4859
row = layout.row()

0 commit comments

Comments
 (0)