ZumoLabs / zpy

Synthetic data for computer vision. An open source toolkit using Blender and Python.
GNU General Public License v3.0
304 stars 35 forks source link

TypeError: expected str, bytes or os.PathLike object, not NoneType #32

Closed VictorAtPL closed 3 years ago

VictorAtPL commented 3 years ago

Describe the bug After upgrade to 0.9.10 (using in Blender 2.91) I need to specify ASSETS environment variable and I need to have 'lib/hdris/1k' directory there.

Otherwise I get following error being thrown:

Traceback (most recent call last):
  File "/home/piotr/Files/blender/blender-2.91.0-linux64/2.91/scripts/modules/addon_utils.py", line 351, in enable
    mod = __import__(module_name)
  File "/home/piotr/repos/zpy/zpy_addon/__init__.py", line 46, in <module>
    import zpy
  File "/home/piotr/repos/zpy/zpy/__init__.py", line 33, in <module>
    from zpy import hdris
  File "/home/piotr/repos/zpy/zpy/hdris.py", line 65, in <module>
    Path(os.environ.get('ASSETS')) / Path('lib/hdris/1k'),
  File "/home/piotr/Files/blender/bar/lib/python3.7/pathlib.py", line 1022, in __new__
    self = cls._from_parts(args, init=False)
  File "/home/piotr/Files/blender/bar/lib/python3.7/pathlib.py", line 669, in _from_parts
    drv, root, parts = self._parse_args(args)
  File "/home/piotr/Files/blender/bar/lib/python3.7/pathlib.py", line 653, in _parse_args
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Expected behavior Specyfing ASSETS env variable is optional. Mention in documentation about such env variable.

Current workaround

  1. mkdir ../assets/lib/hdris/1k
  2. ASSETS=$(pwd)/../assets blender
hu-po commented 3 years ago

We have changed the Suzanne Part 3 example to explicitly set the $ASSETS environment variable so it is more clear. We have also modified the default behavior of zpy.hdris.random_hdri() and zpy.material.random_texture_mat() to check for this environment variable and warn if it cannot find it (defaults to blendfile path). Full changes here: https://github.com/ZumoLabs/zpy/commit/00923d7e8221d74aeb81a38515d8bf9090b2ab83

Thanks for making these tickets!