Inkscape.org
Creating New Extensions Module not found error using Terminal on macOS
  1. #1
    Gavin Johnson Gavin Johnson @snow6oy

    Hi

    I am porting an extension to macOS (Catalina) and running Inkscape 1.1.1. On ubuntu the extension works from either the UI or the CLI. I set PYTHONPATH to /usr/share/inkscape/extensions. On macOS I tried the same trick.

    export PYTHONPATH='/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions/'

    which causes inkex to be imported, but then fail with lxml Module not found errors. The module exists in site-packages so I am puzzled why inkex does not see it.

    Any idea?

    Gavin

  2. #2
    Gavin Johnson Gavin Johnson @snow6oy

    Hello, after a bit more digging I got this to work as follows. Firstly here is a test without PYTHONPATH

    % echo $PYTHONPATH
    % python -c "import inkex" 
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    ModuleNotFoundError: No module named 'inkex'

    Then hydrate the shell environment and try again

    % source ~/.zshenv
    % echo $PYTHONPATH
    /Applications/Inkscape.app/Contents/Resources/lib/python3.8/site-packages:/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions
    % python -c "import inkex"
    

    What I learnt is that site-packages needs to come before extensions. 

Inkscape Inkscape.org Inkscape Forum Creating New Extensions Module not found error using Terminal on macOS