0
$\begingroup$

I am trying to use the pynwb library in my Blender addon and followed advice from several threads. Pip runs and returns "Requirement already satisfied" messages, but the pynwb module is not found. Any advice would be greatly appreciated.

Based on this thread: How to write my add-on so that when installed it also installs dependencies (let's say: scipy or numpy-quaternion)?

I tried this approach:

import bpy
import subprocess

#https://blender.stackexchange.com/questions/149944/how-to-write-my-add-on-so-that-when-installed-it-also-installs-dependencies-let/153520#153520

py_exec = bpy.app.binary_path_python
# ensure pip is installed & update
subprocess.call([str(py_exec), "-m", "ensurepip", "--user"])
subprocess.call([str(py_exec), "-m", "pip", "install", "--upgrade", "pip"])
# install dependencies using pip
# dependencies such as 'numpy' could be added to the end of this command's list
subprocess.call([str(py_exec),"-m", "pip", "install", "--user", "pynwb"])

import pynwb

Based on this thread: Install pip and packages from within Blender OS independently

I tried this approach:

import bpy
import subprocess
import ensurepip
ensurepip.bootstrap()
pybin = bpy.app.binary_path_python
subprocess.check_call([pybin, '-m', 'pip', 'install', 'pynwb'])

import pywnb

Both approaches return the following error:

Looking in links: C:\Users\meowm\AppData\Local\Temp\tmpffsgzmav
Requirement already satisfied: setuptools in c:\program files\blender foundation\blender 2.83\2.83\python\lib\site-packages (40.8.0)
Requirement already satisfied: pip in c:\program files\blender foundation\blender 2.83\2.83\python\lib\site-packages (20.2.1)
Requirement already satisfied: pynwb in c:\users\meowm\appdata\roaming\python\python37\site-packages (1.3.3)
Requirement already satisfied: numpy>=1.16 in c:\program files\blender foundation\blender 2.83\2.83\python\lib\site-packages (from pynwb) (1.17.0)
Requirement already satisfied: pandas>=0.23 in c:\users\meowm\appdata\roaming\python\python37\site-packages (from pynwb) (1.1.0)
Requirement already satisfied: h5py>=2.9 in c:\users\meowm\appdata\roaming\python\python37\site-packages (from pynwb) (2.10.0)
Requirement already satisfied: hdmf<2,>=1.6.4 in c:\users\meowm\appdata\roaming\python\python37\site-packages (from pynwb) (1.6.4)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\meowm\appdata\roaming\python\python37\site-packages (from pynwb) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in c:\users\meowm\appdata\roaming\python\python37\site-packages (from pandas>=0.23->pynwb) (2020.1)
Requirement already satisfied: six in c:\users\meowm\appdata\roaming\python\python37\site-packages (from h5py>=2.9->pynwb) (1.15.0)
Requirement already satisfied: ruamel.yaml>=0.15 in c:\users\meowm\appdata\roaming\python\python37\site-packages (from hdmf<2,>=1.6.4->pynwb) (0.16.10)
Requirement already satisfied: jsonschema>=2.6.0 in c:\users\meowm\appdata\roaming\python\python37\site-packages (from hdmf<2,>=1.6.4->pynwb) (3.2.0)
Requirement already satisfied: scipy>=1.1 in c:\users\meowm\appdata\roaming\python\python37\site-packages (from hdmf<2,>=1.6.4->pynwb) (1.5.2)
Requirement already satisfied: ruamel.yaml.clib>=0.1.2; platform_python_implementation == "CPython" and python_version < "3.9" in c:\users\meowm\appdata\roaming\python\python37\site-packages (from ruamel.yaml>=0.15->hdmf<2,>=1.6.4->pynwb) (0.2.0)
Requirement already satisfied: importlib-metadata; python_version < "3.8" in c:\users\meowm\appdata\roaming\python\python37\site-packages (from jsonschema>=2.6.0->hdmf<2,>=1.6.4->pynwb) (1.7.0)
Requirement already satisfied: pyrsistent>=0.14.0 in c:\users\meowm\appdata\roaming\python\python37\site-packages (from jsonschema>=2.6.0->hdmf<2,>=1.6.4->pynwb) (0.16.0)
Requirement already satisfied: setuptools in c:\program files\blender foundation\blender 2.83\2.83\python\lib\site-packages (from jsonschema>=2.6.0->hdmf<2,>=1.6.4->pynwb) (40.8.0)
Requirement already satisfied: attrs>=17.4.0 in c:\users\meowm\appdata\roaming\python\python37\site-packages (from jsonschema>=2.6.0->hdmf<2,>=1.6.4->pynwb) (19.3.0)
Requirement already satisfied: zipp>=0.5 in c:\users\meowm\appdata\roaming\python\python37\site-packages (from importlib-metadata; python_version < "3.8"->jsonschema>=2.6.0->hdmf<2,>=1.6.4->pynwb) (3.1.0)
Traceback (most recent call last):
  File "\Text", line 11, in <module>
ModuleNotFoundError: No module named 'pywnb'
$\endgroup$
9
  • $\begingroup$ Seems like a typo, the package pynwb is installed, but you're trying to import pywnb (at least in the second example). $\endgroup$
    – Robert Gützkow
    Aug 5, 2020 at 19:42
  • $\begingroup$ Unfortunately fixing the typo did not fix the problem $\endgroup$
    – Marike
    Aug 5, 2020 at 20:21
  • $\begingroup$ What is the error message now? $\endgroup$
    – Robert Gützkow
    Aug 5, 2020 at 20:23
  • $\begingroup$ Using the import format from the tutorials still gives the original error: ModuleNotFoundError: No module named 'pynwb' $\endgroup$
    – Marike
    Aug 5, 2020 at 20:52
  • $\begingroup$ Have you tried adding the the user site-package directory to sys.path or alternatively uninstall the package and then reinstall without the --user flag? $\endgroup$
    – Robert Gützkow
    Aug 5, 2020 at 21:22

0

You must log in to answer this question.

Browse other questions tagged .