Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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
    • Recent
    • Tags
    • Users
    • Login

    Unicode Module Import

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 383 Views
    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.
    • H Offline
      Helper
      last edited by

      On 12/05/2014 at 10:53, xxxxxxxx wrote:

      My Python plugin includes several modules, and I'm using sys.path.insert (and pop) as described elsewhere to import those modules. I've just discovered, though, that this doesn't seem to work with unicode. As far as I can tell, Python doesn't pass unicode strings to sys.path (on Windows at least - haven't tested mac).

      Because the recommended install location for C4D plugins is the user prefs folder, this causes module loading to fail if the user has a username with accented (unicode) characters.

      Is there any way around this, or is it a fundamental limitation at this point? Have others run into this? Do people with accented names usually use an ascii-equivalent username (sorry for my American English naivete - yes, I'm leaving the accents out of that word because I can't be bothered with unicode).

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 14/05/2014 at 12:31, xxxxxxxx wrote:

        Can you please post a short piece of code how you construct the path?

        Bye, s_rath

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 14/05/2014 at 14:52, xxxxxxxx wrote:

            
          import os,sys   
          base_path = unicode(os.path.dirname(__file__),'utf-8')   
          lib_path = os.path.join(os.path.dirname(__file__), 'lib')   
          sys.path.insert(0, lib_path)   
          try:   
              import cvToolboxCore   
              import cvMenus   
          finally:   
              sys.path.pop(0)   
          
          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 14/05/2014 at 14:55, xxxxxxxx wrote:

            Found a few articles that may relate to the issue.

            http://bugs.python.org/issue9425

            http://bytes.com/topic/python/answers/39705-unicode-entries-sys-path

            http://stackoverflow.com/questions/18115618/is-it-possible-to-load-python-module-from-unicode-path-on-windows

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 15/05/2014 at 02:59, xxxxxxxx wrote:

              From the bug-reports you posted it seems really to be in issue, that only seems to be fixed in Python 3.2. I will take a look if there is a workaround for this.

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