-2

I have just recently started to use .qmd for python codes. My issue is that numpy works if I run a cell in vs code simple, but cannot be found if the notebook is to render...

I enclose a screenshot about the error. What is going wrong, and how can I fix it?

enter image description here

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
  • Welcome back to Stack Overflow. As a gentle reminder, this is **not a discussion forum** - please do not "sign off" on posts, or talk about your skill level or anything else conversation. Instead, focus on **asking** a *clear, specific* question. I [edit]ed the post to attempt to fix this. – Karl Knechtel Jun 11 '22 at 21:33

1 Answers1

0

In general, numpy works when imported from Quarto, I use it frequently. This problem is likely caused by some environment configuration on your machine.

If VSCode finds a virtual environment on the directory it's running from, it will automatically load it. Therefore, my suggestion to you is:

  • Change to your directory with cd <mydir>
  • Create a new virtual environment in that directory with python3 -m venv .venv
  • Activate the environment
  • Install numpy with python3 -m pip install numpy
  • Run VSCode code . from that directory
  • Run preview again
Lucas A. Meyer
  • 428
  • 3
  • 8