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

quarto preview quarto-book/ does not work #15

Open
kae-vm opened this issue Mar 11, 2024 · 4 comments
Open

quarto preview quarto-book/ does not work #15

kae-vm opened this issue Mar 11, 2024 · 4 comments

Comments

@kae-vm
Copy link

kae-vm commented Mar 11, 2024

I tried to run the command quarto preview quarto-book/, but it's throwing an error. What do I do?

Preparing to preview
[ 1/10] index.qmd
[ 2/10] intro.qmd
[ 3/10] random-variables.qmd

Starting python3 kernel...Done

Executing 'random-variables.ipynb'
  Cell 1/11: ''...Done
  Cell 2/11: ''...

An error occurred while executing the following cell:
------------------
model = CmdStanModel(stan_file = "stan/flip.stan")
------------------


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[2], line 1
----> 1 model = CmdStanModel(stan_file = "stan/flip.stan")

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\cmdstanpy\model.py:215, in CmdStanModel.__init__(self, model_name, stan_file, exe_file, force_compile, stanc_options, cpp_options, user_header, compile)
    211 if not cmdstan_version_before(
    212     2, 27
    213 ):  # unknown end of version range
    214     try:
--> 215         model_info = self.src_info()
    216         if 'parameters' in model_info:
    217             self._fixed_param |= len(model_info['parameters']) == 0

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\cmdstanpy\model.py:321, in CmdStanModel.src_info(self)
    319 if self.stan_file is None or cmdstan_version_before(2, 27):
    320     return {}
--> 321 return compilation.src_info(str(self.stan_file), self._compiler_options)

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\cmdstanpy\compilation.py:348, in src_info(stan_file, compiler_options)
    338 def src_info(
    339     stan_file: str, compiler_options: CompilerOptions
    340 ) -> Dict[str, Any]:
    341     """
    342     Get source info for Stan program file.
    343
    344     This function is used in the implementation of
    345     :meth:`CmdStanModel.src_info`, and should not be called directly.
    346     """
    347     cmd = (
--> 348         [os.path.join(cmdstan_path(), 'bin', 'stanc' + EXTENSION)]
    349         # handle include-paths, allow-undefined etc
    350         + compiler_options.compose_stanc(None)
    351         + ['--info', str(stan_file)]
    352     )
    353     proc = subprocess.run(cmd, capture_output=
@mitzimorris
Copy link
Collaborator

do you have CmdStanPy and CommandStan installed? cf: https://mc-stan.org/cmdstanpy/installation.html

@kae-vm
Copy link
Author

kae-vm commented Mar 14, 2024

I installed them, then this error is showing

Preparing to preview
[1/8] random-variables.qmd

Starting python3 kernel...Done

Executing 'random-variables.ipynb'
  Cell 1/11: ''...Done
  Cell 2/11: ''...

An error occurred while executing the following cell:
------------------
model = CmdStanModel(stan_file = "stan/flip.stan")
------------------


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[2], line 1
----> 1 model = CmdStanModel(stan_file = "stan/flip.stan")

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\cmdstanpy\model.py:260, in CmdStanModel.__init__(self, model_name, stan_file, exe_file, force_compile, stanc_options, cpp_options, user_header, compile)
    257         get_logger().debug("TBB already found in load path")
    259 if compile and self._exe_file is None:
--> 260     self.compile(force=str(compile).lower() == 'force', _internal=True)

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\cmdstanpy\model.py:513, in CmdStanModel.compile(self, force, stanc_options, cpp_options, user_header, override_options, _internal)
    510         else:
    511             self._compiler_options.add(compiler_options)
--> 513 self._exe_file = compilation.compile_stan_file(
    514     str(self.stan_file),
    515     force=force,
    516     stanc_options=self._compiler_options.stanc_options,
    517     cpp_options=self._compiler_options.cpp_options,
    518     user_header=self._compiler_options.user_header,
    519 )

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\cmdstanpy\compilation.py:475, in compile_stan_file(src, force, stanc_options, cpp_options, user_header)
    468     if 'PCH' in console or 'precompiled header' in console:
    469         get_logger().warning(
    470             "CmdStan's precompiled header (PCH) files "
    471             "may need to be rebuilt."
    472             "Please run cmdstanpy.rebuild_cmdstan().\

@bob-carpenter
Copy link
Owner

Can you do some simpler diagnostics:

  1. Can you run a notebook of whatever kind you're running without including Stan?
  2. Can you run Stan not in a notebook setting?

It looks like the problem may be that you need to rebuild cmdstan. Try this from within Python:

> import cmdstanpy as csp
> csp.rebuild_cmdstan()

CmdStan needs to be rebuilt whenever the binary in the back end changes, which if you'e on a Mac, is pretty much every time Xcode updates if you haven't plugged in a custom C++ toolchain.

@kae-vm
Copy link
Author

kae-vm commented Mar 14, 2024

Can you elaborate on what you mean by not in a notebook setting? I tried running those commands within Python, and it still seems to be throwing me an error.

Python 3.12.2 (tags/v3.12.2:6abddd9, Feb  6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cmdstanpy as csp
>>> csp.rebuild_cmdstan()
Traceback (most recent call last):
  File "C:\Users\keval\AppData\Local\Programs\Python\Python312\Lib\site-packages\cmdstanpy\utils\command.py", line 42, in do_command
    proc = subprocess.Popen(
           ^^^^^^^^^^^^^^^^^
  File "C:\Users\keval\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\keval\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1538, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\keval\AppData\Local\Programs\Python\Python312\Lib\site-packages\cmdstanpy\install_cmdstan.py", line 252, in clean_all
    do_command(cmd, fd_out=None)
  File "C:\Users\keval\AppData\Local\Programs\Python\Python312\Lib\site-packages\cmdstanpy\utils\command.py", line 79, in do_command
    raise RuntimeError(msg) from e
RuntimeError: Command: ['mingw32-make', 'clean-all']
failed with error [WinError 2] The system cannot find the file specified


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\keval\AppData\Local\Programs\Python\Python312\Lib\site-packages\cmdstanpy\install_cmdstan.py", line 388, in rebuild_cmdstan
    clean_all(verbose)
  File "C:\Users\keval\AppData\Local\Programs\Python\Python312\Lib\site-packages\cmdstanpy\install_cmdstan.py", line 256, in clean_all
    raise CmdStanInstallError(f'Command "make clean-all" failed\n{str(e)}')
cmdstanpy.install_cmdstan.CmdStanInstallError: Command "make clean-all" failed
Command: ['mingw32-make', 'clean-all']
failed with error [WinError 2] The system cannot find the file specified

>>>

I am on Windows, btw

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

3 participants