jboynyc / textnets

Text analysis with networks.
https://textnets.readthedocs.io/
GNU General Public License v3.0
284 stars 23 forks source link

Bug when importing the package #40

Closed yaotianzhang closed 2 years ago

yaotianzhang commented 2 years ago

Description

import textnets as tn
import pandas as pd
tn.params["seed"] = 42
corpus = tn.Corpus.from_csv('test.csv')
OSError                                   Traceback (most recent call last)
<ipython-input-25-b587c93effa1> in <module>
----> 1 import textnets as tn
      2 import pandas as pd
      3 tn.params["seed"] = 42
      4 
      5 corpus = tn.Corpus.from_csv('test.csv')

~/opt/anaconda3/lib/python3.8/site-packages/textnets/__init__.py in <module>
     17 from .config import init_seed, params  # noqa: F401
     18 from .corpus import Corpus  # noqa: F401
---> 19 from .network import Textnet  # noqa: F401
     20 
     21 __all__ = [

~/opt/anaconda3/lib/python3.8/site-packages/textnets/network.py in <module>
     25     from cached_property import cached_property  # type: ignore
     26 
---> 27 import igraph as ig
     28 import leidenalg as la
     29 import numpy as np

~/opt/anaconda3/lib/python3.8/site-packages/igraph/__init__.py in <module>
     90 from igraph.cut import Cut, Flow
     91 from igraph.configuration import Configuration, init as init_configuration
---> 92 from igraph.drawing import BoundingBox, DefaultGraphDrawer, Plot, Point, Rectangle, plot
     93 from igraph.drawing.colors import (
     94     Palette,

~/opt/anaconda3/lib/python3.8/site-packages/igraph/drawing/__init__.py in <module>
     26 from igraph.configuration import Configuration
     27 from igraph.drawing.colors import Palette, palettes
---> 28 from igraph.drawing.graph import DefaultGraphDrawer, MatplotlibGraphDrawer
     29 from igraph.drawing.utils import (
     30     BoundingBox,

~/opt/anaconda3/lib/python3.8/site-packages/igraph/drawing/graph.py in <module>
     25 )
     26 from igraph.drawing.colors import color_to_html_format, color_name_to_rgb
---> 27 from igraph.drawing.edge import ArrowEdgeDrawer
     28 from igraph.drawing.text import TextAlignment, TextDrawer
     29 from igraph.drawing.metamagic import AttributeCollectorBase

~/opt/anaconda3/lib/python3.8/site-packages/igraph/drawing/edge.py in <module>
     18 from math import atan2, cos, pi, sin, sqrt
     19 
---> 20 cairo = find_cairo()
     21 
     22 

~/opt/anaconda3/lib/python3.8/site-packages/igraph/drawing/utils.py in find_cairo()
    436     for module_name in module_names:
    437         try:
--> 438             module = __import__(module_name)
    439             break
    440         except ImportError:

~/opt/anaconda3/lib/python3.8/site-packages/cairocffi/__init__.py in <module>
     46 
     47 
---> 48 cairo = dlopen(
     49     ffi, ('cairo-2', 'cairo', 'libcairo-2'),
     50     ('libcairo.so.2', 'libcairo.2.dylib', 'libcairo-2.dll'))

~/opt/anaconda3/lib/python3.8/site-packages/cairocffi/__init__.py in dlopen(ffi, library_names, filenames)
     43     error_message = '\n'.join(  # pragma: no cover
     44         str(exception) for exception in exceptions)
---> 45     raise OSError(error_message)  # pragma: no cover
     46 

OSError: no library called "cairo-2" was found
no library called "cairo" was found
no library called "libcairo-2" was found
cannot load library 'libcairo.so.2': dlopen(libcairo.so.2, 2): image not found
cannot load library 'libcairo.2.dylib': dlopen(libcairo.2.dylib, 2): image not found
cannot load library 'libcairo-2.dll': dlopen(libcairo-2.dll, 2): image not found

When we import textnets package, something goes wrong

We have tried:
pip install cairosvg
pip install cairocffi

But it didn't work, we haven't found a way to solve it now. Any advise would be highly appreciated.

jboynyc commented 2 years ago

Which operating system are you on? Did you install textnets via pip or conda?

jboynyc commented 2 years ago

I cannot address this issue without additional information about the platform and how the package was installed.