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

Install pygraphviz fails #168

Open
nailend opened this issue Mar 27, 2024 · 1 comment
Open

Install pygraphviz fails #168

nailend opened this issue Mar 27, 2024 · 1 comment

Comments

@nailend
Copy link
Collaborator

nailend commented Mar 27, 2024

z/graphviz_wrap.c -o build/temp.linux-x86_64-cpython-310/pygraphviz/graphviz_wrap.o
      pygraphviz/graphviz_wrap.c:3020:10: fatal error: graphviz/cgraph.h: No such file or directory
       3020 | #include "graphviz/cgraph.h"
            |          ^~~~~~~~~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pygraphviz
Failed to build pygraphviz

Install this: sudo apt-get install python3-dev graphviz libgraphviz-dev pkg-config and then pip install pygraphviz in your environment
source

@nailend
Copy link
Collaborator Author

nailend commented Mar 27, 2024

@SabineHaas In case you want to plot graphs with pygraphviz

e.g. BEV component

def draw_graph(energysystem):
    # Draw the graph

    from oemof.network.graph import create_nx_graph

    G = create_nx_graph(energysystem)

    # Specify layout and draw the graph
    pos = nx.drawing.nx_agraph.graphviz_layout(
        G, prog="neato", args="-Gepsilon=0.0001"
    )

    fig, ax = plt.subplots(figsize=(10, 8))
    node_colors = list()
    for i in list(G.nodes()):
        if "storage" in i:
            node_colors.append("royalblue")
        elif "BEV-V2G" in i:
            node_colors.append("firebrick")
        elif "BEV-G2V" in i:
            node_colors.append("lightblue")
        elif "BEV-inflex" in i:
            node_colors.append("darkviolet")
        elif "excess" in i:
            node_colors.append("green")
        elif "shortage" in i:
            node_colors.append("yellow")
        elif "load" in i:
            node_colors.append("orange")
        elif "wind" in i:
            node_colors.append("pink")
        elif "bus" in i:
            node_colors.append("grey")
        else:
            node_colors.append("violet")

    nx.draw(
        G,
        pos,
        # **options,
        with_labels=True,
        node_size=3000,
        # node_color='lightblue',
        font_size=10,
        font_weight="bold",
        node_color=node_colors,
        # node_color=["red", "blue", "green", "yellow", "orange"],
    )
    labels = nx.get_edge_attributes(G, "weight")
    nx.draw_networkx_edge_labels(G, pos=pos, edge_labels=labels)

    # Customize the plot as needed
    ax.set_title("OEMOF Energy System Graph")

    # Show the plot
    plt.show()
    ```

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

1 participant