`show_bloq` not working

Abierto Apto para principiantes
#2,007 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
66/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
jupyter, python
Área
backend

Línea de trabajo

Empieza en qualtran/drawing/_show_funcs.py y qualtran/drawing/graphviz.py; después, sigue el recorrido de cómo show_bloq representa un grafo mediante pydot. El traceback muestra que la representación falla porque el ejecutable dot de Graphviz no está en PATH; consulta las instrucciones de instalación del proyecto y las pruebas relacionadas para saber cómo se espera que se gestione esta dependencia. La tarea estará terminada cuando el ejemplo mínimo funcione o proporcione instrucciones claras a los usuarios cuando dot no esté disponible.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

The show_bloq feature is not working. For example in the first tutorial "wiring up", I get the following FileNotFound error

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
File [~/Qualtran/.venv/lib/python3.14/site-packages/pydot/core.py:1824](http://localhost:8889/lab/tree/tutorials/quantum-programming/.venv/lib/python3.14/site-packages/pydot/core.py#line=1823), in Dot.create(self, prog, format, encoding)
   1823 try:
-> 1824     stdout_data, stderr_data, process = call_graphviz(
   1825         program=prog,
   1826         arguments=arguments,
   1827         working_dir=tmp_dir,
   1828     )
   1829 except OSError as e:

File [~/Qualtran/.venv/lib/python3.14/site-packages/pydot/core.py:249](http://localhost:8889/lab/tree/tutorials/quantum-programming/.venv/lib/python3.14/site-packages/pydot/core.py#line=248), in call_graphviz(program, arguments, working_dir, **kwargs)
    247 program_with_args = [program] + arguments
--> 249 process = subprocess.Popen(
    250     program_with_args,
    251     env=env,
    252     cwd=working_dir,
    253     shell=False,
    254     stderr=subprocess.PIPE,
    255     stdout=subprocess.PIPE,
    256     **kwargs,
    257 )
    258 stdout_data, stderr_data = process.communicate()

File [/usr/lib/python3.14/subprocess.py:1039](http://localhost:8889/usr/lib/python3.14/subprocess.py#line=1038), in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
   1036             self.stderr = io.TextIOWrapper(self.stderr,
   1037                     encoding=encoding, errors=errors)
-> 1039     self._execute_child(args, executable, preexec_fn, close_fds,
   1040                         pass_fds, cwd, env,
   1041                         startupinfo, creationflags, shell,
   1042                         p2cread, p2cwrite,
   1043                         c2pread, c2pwrite,
   1044                         errread, errwrite,
   1045                         restore_signals,
   1046                         gid, gids, uid, umask,
   1047                         start_new_session, process_group)
   1048 except:
   1049     # Cleanup if the child failed starting.

File [/usr/lib/python3.14/subprocess.py:1990](http://localhost:8889/usr/lib/python3.14/subprocess.py#line=1989), in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
   1989 if err_filename is not None:
-> 1990     raise child_exception_type(errno_num, err_msg, err_filename)
   1991 else:

FileNotFoundError: [Errno 2] No such file or directory: 'dot'

During handling of the above exception, another exception occurred:

FileNotFoundError                         Traceback (most recent call last)
Cell In[4], line 2
      1 from qualtran.drawing import show_bloq
----> 2 show_bloq(do_nothing)

File [~/Qualtran/qualtran/drawing/_show_funcs.py:40](http://localhost:8889/lab/tree/tutorials/quantum-programming/qualtran/drawing/_show_funcs.py#line=39), in show_bloq(bloq, type)
     38 type = type.lower()
     39 if type == 'graph':
---> 40     show_bloq_graph(bloq)
     41 elif type == 'dtype':
     42     show_bloq_dtype_graph(bloq)

File [~/Qualtran/qualtran/drawing/_show_funcs.py:151](http://localhost:8889/lab/tree/tutorials/quantum-programming/qualtran/drawing/_show_funcs.py#line=150), in show_bloq_graph(bloq)
    147 import IPython.display
    149 from .graphviz import PrettyGraphDrawer
--> 151 IPython.display.display(PrettyGraphDrawer(bloq).get_svg())

File [~/Qualtran/qualtran/drawing/graphviz.py:369](http://localhost:8889/lab/tree/tutorials/quantum-programming/qualtran/drawing/graphviz.py#line=368), in GraphDrawer.get_svg(self)
    367 def get_svg(self) -> IPython.display.SVG:
    368     """Get an IPython SVG object displaying the graph."""
--> 369     return IPython.display.SVG(self.get_svg_bytes())

File [~/Qualtran/qualtran/drawing/graphviz.py:365](http://localhost:8889/lab/tree/tutorials/quantum-programming/qualtran/drawing/graphviz.py#line=364), in GraphDrawer.get_svg_bytes(self)
    363 def get_svg_bytes(self) -> bytes:
    364     """Get the SVG code (as bytes) for drawing the graph."""
--> 365     return self.get_graph().create(prog='dot', format='svg', encoding='utf-8')

File [~/Qualtran/.venv/lib/python3.14/site-packages/pydot/core.py:1833](http://localhost:8889/lab/tree/tutorials/quantum-programming/.venv/lib/python3.14/site-packages/pydot/core.py#line=1832), in Dot.create(self, prog, format, encoding)
   1831     args = list(e.args)  # type: ignore
   1832     args[1] = f'"{prog}" not found in path.'  # type: ignore
-> 1833     raise OSError(*args)
   1834 else:
   1835     raise

FileNotFoundError: [Errno 2] "dot" not found in path.

I've installed qualtran and dependencies from the repository. I'm using the latest version of jupyter-lab (4.6.6) from pip. I run into the same error when using vscode with jupyter extension.

Minimal code that produces the error:

from qualtran import BloqBuilder
from qualtran import QInt
from qualtran.drawing import show_bloq


# Start program construction
bb = BloqBuilder()

# Add input/output registers named 'x'
x = bb.add_register('x', QInt(8))

do_nothing = bb.finalize(x=x)

show_bloq(do_nothing)
Lenguaje dominante
Python
Estrellas
397
Forks
127
Merge medio
2 d 19 h
PR fusionados (30 d)
4

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de quantumlib/Qualtran

Todos los issues de quantumlib/Qualtran

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.