-3

I have installed Anaconda (with Python 3.9) and Python (3.11) separately. After installing VS Code, I have also created a separated Anaconda environment Env01 . Now, when I open a VS Code file, I have three available environments to choose from

a) base Python 3.11

b) base Conda 3.9

c) Env01

I've chosen Env01 as my interpreter using Ctrl+Shift+P since I understand Anaconda comes with NumPy, Pandas, SciPy and MatPlotlib.

However, when I try to run

import numpy as np

I still get an error that reads

ModuleNotFoundError: No module named 'numpy'

How do I resolve this?

newtothis
  • 495
  • 3
  • 10
  • 1
    You need to install numpy in Env01. Activate the environment and then install numpy in the environment. As far as I know the Anaconda base enviroment (if you do a full blown anaconda installation) will have a boatload of packages in it. But creating new environments doesn't mean that happens in every new environment. You can also manage environments in your Anaconda navigator (somewhere) but I have always just done package installations and updates in a command line. – topsail Jan 28 '23 at 17:41
  • How do I install packages in a specific environment? Do I navigate to that environment path on the command line and then install it as usual? – newtothis Jan 28 '23 at 18:17
  • This looks like a good intro just to get started: https://towardsdatascience.com/manage-your-python-virtual-environment-with-conda-a0d2934d5195 – topsail Jan 28 '23 at 20:19

1 Answers1

1

How did you install the package?

If you choose the Env01 environment which is an conda environment.

You have to install package by using command conda install packageName after using "Ctrl+Shift+P" and typing "Python: Select Interpreter".

Read document for more details.

MingJie-MSFT
  • 5,569
  • 1
  • 2
  • 13
  • So I would have to install all the packages that come with Anaconda in this way, in `Env01`? – newtothis Feb 01 '23 at 07:31
  • @newtothis Yes, the purpose of using virtual environment is to isolate the packages of different environments and prevent errors. You can read [document](https://code.visualstudio.com/docs/python/environments) for more details. – MingJie-MSFT Feb 01 '23 at 07:35
  • Yes, that was why I created a different environment, but I wasn't sure how to install the packages. Thanks. – newtothis Feb 01 '23 at 07:57