abey79/vsketch

Problems importing library (cli.result_callback seems to be undefined)

Closed this issue · 5 comments

flxai commented

I have troubles importing the library using Python 3.9 within a Miniconda environment. After installation (using the approach from prettymaps) and creating a new environment I try to import vsketch which gives the following stack trace:

$ conda create -n default
$ conda activate default
$ pip install git+https://github.com/abey79/vsketch#egg=vsketch
$ python3.9 -c 'import vsketch'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/user/.miniconda3/envs/default/lib/python3.9/site-packages/vsketch/__init__.py", line 3, in <module>
    from .sketch_class import Param, ParamType, SketchClass
  File "/home/user/.miniconda3/envs/default/lib/python3.9/site-packages/vsketch/sketch_class.py", line 10, in <module>
    from .vsketch import Vsketch
  File "/home/user/.miniconda3/envs/default/lib/python3.9/site-packages/vsketch/vsketch.py", line 22, in <module>
    import vpype_cli
  File "/home/user/.miniconda3/envs/default/lib/python3.9/site-packages/vpype_cli/__init__.py", line 5, in <module>
    from .blocks import *
  File "/home/user/.miniconda3/envs/default/lib/python3.9/site-packages/vpype_cli/blocks.py", line 7, in <module>
    from .cli import BlockProcessor, cli, execute_processors
  File "/home/user/.miniconda3/envs/default/lib/python3.9/site-packages/vpype_cli/cli.py", line 126, in <module>
    @cli.result_callback()
TypeError: 'NoneType' object is not callable

Here's a more detailed log of trying to import vsketch using ipython.

Since I couldn't find anything in the issue tracker: Is the libary compatible with Python 3.9?

Hello @flxai. Yes, vsketch is compatible with Python 3.9. Your error appears to be related to Shiboken, which is in turn is linked to PySide2. Although I've seen this sort of things in the past I can't quite remember how to fix it. What's your OS?

flxai commented

Thanks for pointing that out. Overlooked that in the more detailed log. I'll look into it. Do you remember any past issues that are connected to Shiboken? The OS is Arch Linux.

flxai commented

@abey79 Just in case I'd need to highlight you.

@flxai Yeah PySide2/Shiboken is sometime painful to install. I have no experience with Arch linux whatsoever but, from my experience with other platform, I would suggest to reinstall in a way that leans as much as possible on the OS's packages:

  • If you havent done so, install python 3.9 with the OS package manager and make 100% sure that this is indeed the python executable you are using in the subsequent steps.
  • Install the pyside2 package and while you're at it the Shapely package.
  • Avoid using conda/miniconda/anaconda or anything whose name ending resembles "onda" :)
  • Create a bare-bone virtual environment: python -m venv vpype-venv. Important note: normally, if everything is available system-wide in terms of dependences (Qt, GEOS, etc.), pip is rather successful at reinstalling stuff in the virtual env. However, it sometimes fails. In this case, create your venv with access to system packages so it can directly use the system version of pyside2: python -m venv --system-site-packages vpype-venv.
  • As usual with venv, you always need to activate it: source vpype-venv/bin/activate
  • Install as usual: pip install git+https://github.com/abey79/vsketch#egg=vsketch

If that works, you can likely try your chance with more elaborate venv manager, but I'd rather stick to the OS python interpreter and packages.

Edit: if you have done so already, consider joining DrawingBots discord server. I often hang around there to help.

flxai commented

Thanks for your help and time. Everything works perfectly now without "onda".