macOS¶
It is recommended to use Homebrew to install the dependencies for Boxes.py. See brew.sh on how to install Homebrew.
General¶
Install Python 3 and other dependencies:
brew install python3 git
Optional:
brew install pstoedit
Install cairio:
brew install pkg-config
Install required Python modules:
pip3 install Markdown affine shapely
Download Boxes.py via Git:
git clone https://github.com/florianfesti/boxes.git
Run Boxes.py:
Local web server on port 8000:
./scripts/boxesserver
Command line variant (CLI):
./scripts/boxes
System-wide with Inkscape extension¶
To install Boxes.py system-wide with the Inkscape extension, following steps are required:
Install Inkscape with Homebrew Cask (requires XQuartz):
brew install inkscape
From the root directory of the repository, run:
./setup.py install
Now
boxes
andboxesserver
can be executed like other commands and the Inkscape extension should be available.
Troubleshooting¶
When using the Inkscape extension something like the following error might occur:
Traceback (most recent call last):
File "/Users/martin/.config/inkscape/extensions/boxes", line 107, in <module>
main()
File "/Users/martin/.config/inkscape/extensions/boxes", line 47, in main
run_generator(name, sys.argv[2:])
File "/Users/martin/.config/inkscape/extensions/boxes", line 73, in run_generator
box.close()
File "/usr/local/lib/python3.7/site-packages/boxes-0.1-py3.7.egg/boxes/__init__.py", line 594, in close
svgutil.svgMerge(self.output, self.inkscapefile, out)
File "/usr/local/lib/python3.7/site-packages/boxes-0.1-py3.7.egg/boxes/svgutil.py", line 144, in svgMerge
from lxml import etree as et
ImportError: dlopen(/Applications/Inkscape.app/Contents/Resources/lib/python2.7/site-packages/lxml/etree.so, 2): Symbol not found: _PyBaseString_Type
Referenced from: /Applications/Inkscape.app/Contents/Resources/lib/python2.7/site-packages/lxml/etree.so
Expected in: flat namespace
This is because Inkscape on macOS ships its own version of Python 2.7 where
lxml
and other dependencies are missing.
A workaround is to edit the file at
/Applications/Inkscape.app/Contents/Resources/bin/inkscape
.
At line 79 there should be following code:
export PYTHONPATH="$TOP/lib/python$PYTHON_VERS/site-packages/"
which needs to be changed to
#export PYTHONPATH="$TOP/lib/python$PYTHON_VERS/site-packages/"
This forces Inkscape to use the Python version installed by Homebrew which has all the necessary dependencies installed.
Note: This might break other extensions. In this case simply change the line back and restart Inkscape.