BlenderProc icon indicating copy to clipboard operation
BlenderProc copied to clipboard

blenderproc installed from repo and using 'pip install -e .' doesn't work with Python 3.11

Open Griperis opened this issue 7 months ago • 0 comments

Describe the issue

If blenderproc is installed from the repository using pip install -e . in Python 3.12 everything works, and the command blenderproc prints help. If you have Python 3.11 and use the command above, launching blenderproc fails with an exception.

Hopefully, this isn't specific to my setup, but I tried cleaning python stuff wherever possible.

Traceback (most recent call last):
  File "\\?\C:\Python311\Scripts\blenderproc-script.py", line 33, in <module>
    sys.exit(load_entry_point('blenderproc', 'console_scripts', 'blenderproc')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "\\?\C:\Python311\Scripts\blenderproc-script.py", line 25, in importlib_load_entry_point
    return next(matches).load()
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\importlib\metadata\__init__.py", line 202, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1128, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "c:\users\gripe\polygoniq_projects\blenderproc\blenderproc\__init__.py", line 64, in <module>
    raise RuntimeError("\n###############\nThis script can only be run by \"blenderproc run\", instead of calling:"
RuntimeError:
###############
This script can only be run by "blenderproc run", instead of calling:
        python \\?\C:\Python311\Scripts\blenderproc
call:
        blenderproc run \\?\C:\Python311\Scripts\blenderproc
###############

Leads

I have not investigated whether something changed in how pip bundles packages, but checked out the file_names_on_stack variable, in blenderproc.__init__.py.

In Python 3.11:

['blenderproc-script.py', 'blenderproc-script.py', '__init__.py', '__init__.py', '<frozen importlib._bootstrap>', '<frozen importlib._bootstrap>', '<frozen importlib._bootstrap>', '<frozen importlib._bootstrap>', '<frozen importlib._bootstrap>', '<frozen importlib._bootstrap>', '<frozen importlib._bootstrap>', '<frozen importlib._bootstrap>', '<frozen importlib._bootstrap_external>', '<frozen importlib._bootstrap>', '__init__.py']

In Python 3.12:

['<frozen runpy>', '<frozen runpy>', '__main__.py', '<frozen importlib._bootstrap>', '<frozen importlib._bootstrap>', '<frozen importlib._bootstrap>', '<frozen importlib._bootstrap>', '<frozen importlib._bootstrap>', '<frozen importlib._bootstrap>', '<frozen importlib._bootstrap_external>', '<frozen importlib._bootstrap>', '__init__.py']

In Python 3.12 the condition in blenderproc.__init__.py:L50 passes, in 3.11 I can't see how the command can work without exception.

Minimal code example

# Have Python 3.11
# git clone this repo
pip install -e .
blenderproc

Files required to run the code

No response

Expected behavior

No RuntimeError, the blenderproc works without issues.

BlenderProc version

main

Griperis avatar Jul 30 '24 09:07 Griperis