Troubleshooting graphviz install / python module

31 Views Asked by At

I installed graphviz on my Mac (macOS Monterey, Version 12.4, Apple M1 Max chip) using Homebrew. I think everything worked with the installation, but when I try to import graphviz in a Python (Python 3.12.2) file, but I get the following error:

Traceback (most recent call last):
  File "/Users/name/Dropbox/name/graph.py", line 2, in <module>
    import graphviz
ModuleNotFoundError: No module named 'graphviz'

When I run dot -V, I get this: dot - graphviz version 10.0.1 (20240210.2158). When I run brew info graphviz, I get this output:

==> graphviz: stable 10.0.1 (bottled), HEAD
Graph visualization software from AT&T and Bell Labs
https://graphviz.org/
/opt/homebrew/Cellar/graphviz/10.0.1 (325 files, 13.8MB) *
  Poured from bottle using the formulae.brew.sh API on 2024-03-28 at 10:17:09
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/g/graphviz.rb
License: EPL-1.0
==> Dependencies
Build: autoconf ✘, automake ✘, bison ✘, pkg-config ✔
Required: gd ✔, gts ✔, libpng ✔, librsvg ✔, libtool ✔, pango ✔
==> Options
--HEAD
    Install HEAD version
==> Analytics
install: 39,159 (30 days), 100,696 (90 days), 433,343 (365 days)
install-on-request: 36,904 (30 days), 94,016 (90 days), 406,742 (365 days)
build-error: 455 (30 days)

Also, when I try to use pip (pip3 install graphviz or similar with pygraphviz), I get this:

error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try brew install
    xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a non-brew-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip.
    
    If you wish to install a non-brew packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

All the installation troubleshooting guides seem to use pip, but I haven't seen other people have this error. It's supposed to be fine to just handle graphviz with brew, though, right?

I've tried to follow some other troubleshooting posts, but nothing worked. I'd prefer not to have to install lots of other random packages or package managers, but I'm willing to if I have to. I would really appreciate any help with this! Thanks.

0

There are 0 best solutions below