Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Python Module not found on upgrade

    Cinema 4D SDK
    2
    4
    788
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • FSSF
      FSS
      last edited by

      Hi everyone,

      im trying to upgrade our python module from R21(Python27) to the most recent cinema version 2023.1.0. BuildNumber (CL387487.470010)

      I followed the instructions on the website, https://developers.maxon.net/docs/py/2023_2/manuals/misc/python3_migration.html

      I copied the library-module to the following paths:

      c:\Users\tov\AppData\Roaming\Maxon\Maxon Cinema 4D 2023_BCDB4759_x\python39\libs\

      C:\Users\tov\AppData\Roaming\Maxon\Maxon Cinema 4D 2023_BCDB4759\python39\libs

      C:\Users\tov\AppData\Roaming\Maxon\python\python39\libs

      The library components are not found with the error message:

      Traceback (most recent call last):
        File "C:\Program Files\Maxon Cinema 4D 2023\plugins\vuframe-aura-commandline.pyp", line 31, in <module>
          import VC4D.Recipe as Recipe
        File "C:\Users\tov\AppData\Roaming\Maxon\Maxon Cinema 4D 2023_BCDB4759_x\python39\libs\VC4D\Recipe.py", line 11, in <module>
          from Tools import LogWithTimestamp
      ModuleNotFoundError: No module named 'Tools'
      

      The base plugin which uses the librarys resides in

      C:\Program Files\Maxon Cinema 4D 2023\plugins

      My module contains the usual suspects required:

      __init__.py
      __main__.py
      _version.py
      

      What did i miss?
      Is it required to add a special Path to the systemvariables?

      1 Reply Last reply Reply Quote 0
      • FSSF
        FSS
        last edited by

        So, to answer my own question, seems that importing module components without module qualifiers does no longer work in 3.9?

        from Tools import LogWithTimestamp is wrong

        from VC4D.Tools import LogWithTimestamp is the correct way to go

        ferdinandF 1 Reply Last reply Reply Quote 0
        • ferdinandF
          ferdinand @FSS
          last edited by ferdinand

          Hey @fss,

          Thank you for reaching out to us. Python 3 dropped support for implicit relative imports as they can be ambiguous im complex packages.

          Python 3 makes a distinction between relative and absolute imports, dropping support for implicit relative imports. In Python 2.5+, use from future import absolute_import to get the same behavior as Python 3. To support older versions as well, only use absolute imports. Replace a relative import:

          from xyz import abc
          

          with an absolute import:

          from mypackage.xyz import abc
          

          Another way to deal with this would be to fix your __init__.py's. So, when you want everything in the module/package Tools to be also contained in the package VC4D, you must edit the __init__.py of VC4D

          from .Tools import *
          

          or more selective

          from .Tools import LogWithTimestamp, ...
          

          Cheers,
          Ferdinand

          MAXON SDK Specialist
          developers.maxon.net

          1 Reply Last reply Reply Quote 0
          • FSSF
            FSS
            last edited by FSS

            Thanks alot Ferdinand.

            I investigated some further and added the classes to the plugins list:

            _plugins = [
                "Tools",
                "Recipe",
            

            The error was also caused, by the executables having different libraries. Meaning, we call once cinema 4d.exe, which uses the {prefs}/python39/libs folder.

            The second part of the plugin is executed using the classic Commandline.exe and uses the {prefs}_x/python39/libs folder.

            Im a idiot, but a stubborn one.
            Have a great day.

            Topic can be locked now.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post