### Bug description

I am trying to run quarto preview and getting the following error. The numpy error occurs only within quarto CLI command. This runs fine within in VScode virtual environment 

Note: I am using M1 silicon and tried in arm and intel mode in terminal. Getting error in both the cases. 

.qmd file 
```
---
title: "Quarto Basics"
format:
  html:
    code-fold: true
jupyter: python3
---

For a demonstration of a line plot on a polar axis, see @fig-polar.

```{python}
#| label: fig-polar
#| fig-cap: "A line plot on a polar axis"

import numpy as np
import matplotlib.pyplot as plt

```

quarto preview hello.qmd --no-browser --no-watch-inputs

```
Executing 'hello.ipynb'
  Cell 1/1...ERROR: 

An error occurred while executing the following cell:
------------------

import numpy as np
import matplotlib.pyplot as plt
------------------

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
File ~/Documents/projects/venv3/lib/python3.10/site-packages/numpy/core/__init__.py:23, in <module>
     22 try:
---> 23     from . import multiarray
     24 except ImportError as exc:

File ~/Documents/projects/venv3/lib/python3.10/site-packages/numpy/core/multiarray.py:10, in <module>
      9 import functools
---> 10 from . import overrides
     11 from . import _multiarray_umath

File ~/Documents/projects/venv3/lib/python3.10/site-packages/numpy/core/overrides.py:6, in <module>
      4 import os
----> 6 from numpy.core._multiarray_umath import (
      7     add_docstring, implement_array_function, _get_implementing_args)
      8 from numpy.compat._inspect import getargspec

ImportError: dlopen(/Users/username/Documents/projects/venv3/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so, 0x0002): tried: '/Users/username/Documents/projects/venv3/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/lib/_multiarray_umath.cpython-310-darwin.so' (no such file)

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 import numpy as np
      2 import matplotlib.pyplot as plt

File ~/Documents/projects/venv3/lib/python3.10/site-packages/numpy/__init__.py:140, in <module>
    137 # Allow distributors to run custom init code
    138 from . import _distributor_init
--> 140 from . import core
    141 from .core import *
    142 from . import compat

File ~/Documents/projects/venv3/lib/python3.10/site-packages/numpy/core/__init__.py:49, in <module>
     25     import sys
     26     msg = """
     27 
     28 IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
   (...)
     47 """ % (sys.version_info[0], sys.version_info[1], sys.executable,
     48         __version__, exc)
---> 49     raise ImportError(msg)
     50 finally:
     51     for envkey in env_added:

ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.10 from "/Users/username/Documents/projects/venv3/bin/python3"
  * The NumPy version is: "1.23.2"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: dlopen(/Users/username/Documents/projects/venv3/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so, 0x0002): tried: '/Users/username/Documents/projects/venv3/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/lib/_multiarray_umath.cpython-310-darwin.so' (no such file)

ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.10 from "/Users/username/Documents/projects/venv3/bin/python3"
  * The NumPy version is: "1.23.2"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: dlopen(/Users/username/Documents/projects/venv3/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so, 0x0002): tried: '/Users/username/Documents/projects/venv3/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/lib/_multiarray_umath.cpython-310-darwin.so' (no such file)
```


### `quarto check` Output

```
[✓] Checking Quarto installation......OK
      Version: 1.0.38
      Path: /Applications/quarto/bin

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.10.6
      Path: /Users/username/Documents/projects/venv3/bin/python3
      Jupyter: 4.11.1
      Kernels: python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........(None)

      Unable to locate an installed version of R.
      Install R from https://cloud.r-project.org/
```

### `quarto tools check` Output

```
[✓] Inspecting tools

Tool         Status            Installed     Latest  
chromium     Not installed     ---           869685  
tinytex      Not installed     ---           v2022.08
```

### Checklist

- [X] [formatted your issue](https://yihui.org/issue/#please-format-your-issue-correctly) so it is easier for us to read?
- [X] included a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
- [X] documented the quarto version you're running, by pasting the output from running `quarto check` in the "Quarto Check Output" text area?
- [X] documented the version of the quarto tools you're running, by providing the output from running `quarto tools check` in the "Quarto Tools Check Output" text area?
- [ ] documented the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
- [X] documented which operating system you're running? If on Linux, please provide the specific distribution as well.
- [ ] upgraded to the latest version, including your versions of R, the RStudio IDE, and relevant R packages?
cscheid
2022-08-18T15:49:39Z
anaveenan
documentation
v1.3
closed
python numpy error quarto preview
https://github.com/quarto-dev/quarto-cli/issues/1968