Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using boxes in python virtual environment #144

Closed
dido77-arduino opened this issue Feb 4, 2024 · 9 comments
Closed

using boxes in python virtual environment #144

dido77-arduino opened this issue Feb 4, 2024 · 9 comments

Comments

@dido77-arduino
Copy link

Hi

I would like to use the plugin in a python virtual environment, I am not successful at the moment.

I have setup the venv, cloned the repo and installed the requirements as needed

source $HOME/venv/bin/activate
cat ~/.config/inkscape/extensions/mightyscape-1.2/requirements.txt | sed '/^#/d' | xargs -n 1 pip install --upgrade --no-cache-dir (completed w/o errors)

I have also changed preferences.xml to use the virtual environment

       id="aboutextensions"
       python-interpreter="/home/username/venv/bin/python" />

When I start inkscape and I try any of the Boxes plugins, I receive the error

File` "/home/didomax/.config/inkscape/extensions/mightyscape-1.2/extensions/fablabchemnitz/boxes.py/boxes/scripts/boxes", line 24, in <module>
    import boxes
ModuleNotFoundError: No module named 'boxes'

I tried another plugin (Origami) and it worked w/o glitches.

Where am I missing a step

Thanks
Max

@vmario89
Copy link
Contributor

vmario89 commented Feb 5, 2024

Hi,
can you ensure that boxes installed properly? Maybe it skipped installing due to some error reason?

you can check by

pip list installed | grep boxes

@dido77-arduino
Copy link
Author

dido77-arduino commented Feb 6, 2024

Hi @vmario89

actually no, it was not installed - I was assuming it was part of the requirements.txt, my bad.

I have now tried to install it, but it does not sound to me right

pip install boxes --no-cache-dir
Collecting boxes
  Downloading boxes-0.0.0.tar.gz (7.8 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: boxes
  Building wheel for boxes (setup.py) ... done
  Created wheel for boxes: filename=boxes-0.0.0-py2.py3-none-any.whl size=3111 sha256=bb45319bd050d01002096f3dff2e5f39b43837aed0a923373f972bea94cfc797
  Stored in directory: /tmp/pip-ephem-wheel-cache-a29pnob1/wheels/36/5e/21/04cf0e4703e07bb629c779f063126fb5a618b66d19071dfc38
Successfully built boxes
Installing collected packages: boxes
Successfully installed boxes-0.0.0

And actually boxes.py is empty

cat venv/lib64/python3.10/site-packages/boxes/boxes.py 
# -*- coding: utf-8 -*-

"""Main module."""

This is the full error

stderr: /home/didomax/.config/inkscape/extensions/mightyscape-1.2/extensions/fablabchemnitz/boxes.py/boxes/scripts/boxes:21: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  from pkg_resources import get_distribution
Traceback (most recent call last):
  File "/home/didomax/.config/inkscape/extensions/mightyscape-1.2/extensions/fablabchemnitz/boxes.py/boxes/scripts/boxes", line 24, in <module>
    import boxes
ModuleNotFoundError: No module named 'boxes'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/didomax/.config/inkscape/extensions/mightyscape-1.2/extensions/fablabchemnitz/boxes.py/boxes/scripts/boxes", line 27, in <module>
    import boxes
  File "/home/didomax/.config/inkscape/extensions/mightyscape-1.2/extensions/fablabchemnitz/boxes.py/boxes/scripts/../boxes/__init__.py", line 32, in <module>
    from boxes import formats
  File "/home/didomax/.config/inkscape/extensions/mightyscape-1.2/extensions/fablabchemnitz/boxes.py/boxes/scripts/../boxes/formats.py", line 22, in <module>
    from boxes.drawing import SVGSurface, PSSurface, LBRN2Surface, Context
  File "/home/didomax/.config/inkscape/extensions/mightyscape-1.2/extensions/fablabchemnitz/boxes.py/boxes/scripts/../boxes/drawing.py", line 3, in <module>
    from affine import Affine
ModuleNotFoundError: No module named 'affine'

Which I do not understand, since python is able to find the libraries when called from command line.

Any clue what is going on?

Max

@vmario89
Copy link
Contributor

vmario89 commented Feb 7, 2024

hi, you actually installed the wrong boxes module: https://pypi.org/project/boxes/

please try to install like the following command:

pip install git+https://github.com/florianfesti/boxes.git

then run

boxes

the output will be


boxes.py

Generate stencils for wooden boxes.

Usage:
  boxes <generator> [<args>...]
  boxes --list
  boxes (-h | --help)
  boxes --version

Options:
  -h --help     Show this screen.
  --version     Show version.
  --list        List available generators.

@vmario89
Copy link
Contributor

vmario89 commented Feb 7, 2024

ps: i added the missing dependency in requirements.txt

@dido77-arduino
Copy link
Author

Thanks for the prompt answer.

Some progress done, I can call boxes both from the command line and in the python (virtual) environment

$ boxes.py

Generate stencils for wooden boxes.

Usage:
  boxes <generator> [<args>...]
  boxes --list
  boxes (-h | --help)
  boxes --version

Options:
  -h --help     Show this screen.
  --version     Show version.
  --list        List available generators.

and

Python 3.11.7 (main, Jan  7 2024, 01:05:16) [GCC 13.2.1 20231216] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import boxes
>>> 

However, I get the very same error as in the previous post when trying to run the extension within inkscape. My preferences.xml

<group
     id="extensions"
     org.inkscape.output.png.inkscape.png_bitdepth="99"
     org.inkscape.output.png.inkscape.png_compression="6"
     org.inkscape.output.png.inkscape.png_antialias="2"
     python-interpreter="/home/didomax/venv/bin/python"

I do not know anymore where to look for issues...

@vmario89
Copy link
Contributor

vmario89 commented Feb 9, 2024

looks like i will have to check it myself when using venv (actually never tried). Which OS are you running? Linux, Windows, ... ?

@dido77-arduino
Copy link
Author

dido77-arduino commented Feb 9, 2024 via email

@vmario89
Copy link
Contributor

vmario89 commented Jul 4, 2024

i tested the thing with venv and it can confirm the failure. but good news: most of plugins work really well with venv. i will change mightyscape documentation to use venv mainly because it does not mess with system libraries at all

@vmario89
Copy link
Contributor

vmario89 commented Jul 5, 2024

finally fixed by c5e4801

@vmario89 vmario89 closed this as completed Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants