pixel_to_svg
pixel_to_svg copied to clipboard
Error installing pypotrace
Hi! When I try to run pip install . in pypotrace I get the following error:
Error compiling Cython file:
------------------------------------------------------------
...
self._data = value
# Init potrace bitmap struct
self.po_bitmap.w = self._data.shape[1]
self.po_bitmap.h = self._data.shape[0]
self.po_bitmap.dy = (self.po_bitmap.w + (
(N - (self.po_bitmap.w & (N - 1))) & (N - 1))) / N
^
------------------------------------------------------------
potrace/_potrace.pyx:130:63: Cannot assign type 'double' to 'int'
Error compiling Cython file:
------------------------------------------------------------
...
cdef void setpixel(potrace_bitmap_s *bmp, int x, int y, int on):
"""
Set a pixel on or off in a potrace_bitmap_s.
"""
if on:
bmp.map[y*bmp.dy + x/N] |= (1uL << (N - 1 - x % N))
^
------------------------------------------------------------
potrace/_potrace.pyx:377:15: Invalid index type 'double'
Error compiling Cython file:
------------------------------------------------------------
...
Set a pixel on or off in a potrace_bitmap_s.
"""
if on:
bmp.map[y*bmp.dy + x/N] |= (1uL << (N - 1 - x % N))
else:
bmp.map[y*bmp.dy + x/N] &= ~(1uL << (N - 1 - x % N))
^
------------------------------------------------------------
potrace/_potrace.pyx:379:15: Invalid index type 'double'
I think this is maybe due to version changes? I added an explicit cast to int at every line with issue, which resulted in a functioning installation.
Hi! When I try to run pip install . in pypotrace I get the following error:
Error compiling Cython file: ------------------------------------------------------------ ... self._data = value # Init potrace bitmap struct self.po_bitmap.w = self._data.shape[1] self.po_bitmap.h = self._data.shape[0] self.po_bitmap.dy = (self.po_bitmap.w + ( (N - (self.po_bitmap.w & (N - 1))) & (N - 1))) / N ^ ------------------------------------------------------------ potrace/_potrace.pyx:130:63: Cannot assign type 'double' to 'int' Error compiling Cython file: ------------------------------------------------------------ ... cdef void setpixel(potrace_bitmap_s *bmp, int x, int y, int on): """ Set a pixel on or off in a potrace_bitmap_s. """ if on: bmp.map[y*bmp.dy + x/N] |= (1uL << (N - 1 - x % N)) ^ ------------------------------------------------------------ potrace/_potrace.pyx:377:15: Invalid index type 'double' Error compiling Cython file: ------------------------------------------------------------ ... Set a pixel on or off in a potrace_bitmap_s. """ if on: bmp.map[y*bmp.dy + x/N] |= (1uL << (N - 1 - x % N)) else: bmp.map[y*bmp.dy + x/N] &= ~(1uL << (N - 1 - x % N)) ^ ------------------------------------------------------------ potrace/_potrace.pyx:379:15: Invalid index type 'double'
I think this is maybe due to version changes? I added an explicit cast to int at every line with issue, which resulted in a functioning installation.
It works to install but later when running an image it throws an error:
TypeError Traceback (most recent call last)
Cell In[12], line 39
33 seg = graph_seg(
34 img,
35 thresh=80,
36 )
37 # Given a segmented image, turn it to SVG.
38 # This internally uses `potrace`.
---> 39 svg = to_svg(img, seg)
41 # Convert SVG back to raster to display it
42 # and compare it to original image
43 img2 = render_svg(svg)
File ~/miniconda3/envs/pixel_to_svg/lib/python3.10/site-packages/pixel_to_svg-0.1.0-py3.10.egg/pixel_to_svg/pixel_to_svg.py:35, in to_svg(img, seg, nb_layers, palette, opacity)
33 if np.all(mask==0):
34 continue
---> 35 paths, attrs, svg_attrs = binary_image_to_svg2(mask)
36 for attr in attrs:
37 if palette is None:
File ~/miniconda3/envs/pixel_to_svg/lib/python3.10/site-packages/pixel_to_svg-0.1.0-py3.10.egg/pixel_to_svg/pixel_to_svg.py:115, in binary_image_to_svg2(mask)
109 """
110 same as binary_image_to_svg, but use `pypotrace`
111 instead of calling `potrace` from shell
112 it is more convenient and faster, this way
113 """
114 import potrace
--> 115 bmp = potrace.Bitmap(mask)
116 bmp.trace()
117 xml = bmp.to_xml()
File potrace/_potrace.pyx:42, in potrace._potrace.Bitmap.__init__()
File potrace/_potrace.pyx:138, in potrace._potrace.Bitmap.data.__set__()
File potrace/_potrace.pyx:379, in potrace._potrace.setpixel()
TypeError: 'float' object cannot be interpreted as an integer
getting the same issue:
(base) winkltechnologies@instance-19-mar:~/pypotrace$ pip install .
Processing /home/winkltechnologies/pypotrace
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [120 lines of output]
/opt/conda/lib/python3.10/site-packages/Cython/Compiler/Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /home/winkltechnologies/pypotrace/potrace/_potrace.pxd
tree = Parsing.p_module(s, pxd, full_module_name)
warning: potrace/_potrace.pyx:345:30: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line.
warning: potrace/_potrace.pyx:345:35: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line.
warning: potrace/_potrace.pyx:345:40: Non-trivial type declarators in shared declaration (e.g. mix of pointers and values). Each pointer declaration should be on its own line.
Error compiling Cython file:
------------------------------------------------------------
...
self._data = value
# Init potrace bitmap struct
self.po_bitmap.w = self._data.shape[1]
self.po_bitmap.h = self._data.shape[0]
self.po_bitmap.dy = (self.po_bitmap.w + (
(N - (self.po_bitmap.w & (N - 1))) & (N - 1))) / N
^
------------------------------------------------------------
potrace/_potrace.pyx:130:63: Cannot assign type 'double' to 'int'
Error compiling Cython file:
------------------------------------------------------------
...
cdef void setpixel(potrace_bitmap_s *bmp, int x, int y, int on):
"""
Set a pixel on or off in a potrace_bitmap_s.
"""
if on:
bmp.map[y*bmp.dy + x/N] |= (1uL << (N - 1 - x % N))
^
------------------------------------------------------------
potrace/_potrace.pyx:377:15: Invalid index type 'double'
Error compiling Cython file:
------------------------------------------------------------
...
Set a pixel on or off in a potrace_bitmap_s.
"""
if on:
bmp.map[y*bmp.dy + x/N] |= (1uL << (N - 1 - x % N))
else:
bmp.map[y*bmp.dy + x/N] &= ~(1uL << (N - 1 - x % N))
^
------------------------------------------------------------
potrace/_potrace.pyx:379:15: Invalid index type 'double'
Error compiling Cython file:
------------------------------------------------------------
...
cdef void setpixel(potrace_bitmap_s *bmp, int x, int y, int on):
"""
Set a pixel on or off in a potrace_bitmap_s.
"""
if on:
bmp.map[y*bmp.dy + x/N] |= (1uL << (N - 1 - x % N))
^
------------------------------------------------------------
potrace/_potrace.pyx:377:15: Invalid index type 'double'
Error compiling Cython file:
------------------------------------------------------------
...
cdef void setpixel(potrace_bitmap_s *bmp, int x, int y, int on):
"""
Set a pixel on or off in a potrace_bitmap_s.
"""
if on:
bmp.map[y*bmp.dy + x/N] |= (1uL << (N - 1 - x % N))
^
------------------------------------------------------------
potrace/_potrace.pyx:377:15: Invalid index type 'double'
Error compiling Cython file:
------------------------------------------------------------
...
Set a pixel on or off in a potrace_bitmap_s.
"""
if on:
bmp.map[y*bmp.dy + x/N] |= (1uL << (N - 1 - x % N))
else:
bmp.map[y*bmp.dy + x/N] &= ~(1uL << (N - 1 - x % N))
^
------------------------------------------------------------
potrace/_potrace.pyx:379:15: Invalid index type 'double'
Error compiling Cython file:
------------------------------------------------------------
...
Set a pixel on or off in a potrace_bitmap_s.
"""
if on:
bmp.map[y*bmp.dy + x/N] |= (1uL << (N - 1 - x % N))
else:
bmp.map[y*bmp.dy + x/N] &= ~(1uL << (N - 1 - x % N))
^
------------------------------------------------------------
potrace/_potrace.pyx:379:15: Invalid index type 'double'
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/home/winkltechnologies/pypotrace/setup.py", line 4, in <module>
setup(
File "/home/winkltechnologies/pypotrace/cysetuptools.py", line 162, in setup
cython_ext_modules = cythonize(cython_ext_modules)
File "/opt/conda/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonize
cythonize_one(*args)
File "/opt/conda/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: potrace/_potrace.pyx
Compiling potrace/_potrace.pyx because it changed.
Compiling potrace/bezier.pyx because it changed.
Compiling potrace/svg.pyx because it changed.
Compiling potrace/agg/curves.pyx because it changed.
[1/4] Cythonizing potrace/_potrace.pyx
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the
```package mentioned above, not pip.
hint: See above for details.