0

I am importing libraries which I installed using pip install .. to Jupyter Notebook using the anaconda distribution, which is working. Next I am tryin to import the same libraries in VS Code and running it using Anaconda prompt. I am getting error messages like: ModuleNotFoundError: No module named 'spacy'

I don't understand why it would work in Jupyter notebook but not using VS Code, aren't they both using the Anaconda distribution?

EDIT: I tried using Sublime text editor and got the same error. When using the Anaconda Prompt and running 'pip list' I get a list of all packages including spacy, but when running the code I get an error "No module named 'spacy'"

Tara
  • 31
  • 3
  • Check the python versions you are running on each software. It is most likely that VS code is jacking into the default system python (or another anaconda virtualenv) than the one you worked on in the notebook – Simas Joneliunas May 31 '20 at 23:16
  • In VS Code, I checked which interpreter is being used, and I got this : "C:\Users\My User\AppData\Local\Continuum\anaconda3\python.exe" , which is coming from anaconda. Is this what you mean? – Tara May 31 '20 at 23:21

1 Answers1

0

Usually, this mistake happens if you didn't select the appropriate environment. To switch to anaconda environment in VSCode. Use the "Python: Select Interpreter" command from the Command Palette (Ctrl+Shift+P) then Select the specific environment. You can find more detail in VSCode documentation

Ilyes KAANICH
  • 336
  • 1
  • 3
  • 7
  • Can you help me choose an environment? Right now I have this selected: "~AppData\Local\Continuum\anaconda3\python.exe" It's the only one with anaconda so I'm assuming it is the anaconda environment selected. – Tara May 31 '20 at 23:40
  • Can you check in which conda environment is Jupyter running? here is a helpful link to do so https://stackoverflow.com/questions/37085665/in-which-conda-environment-is-jupyter-executing – Ilyes KAANICH Jun 01 '20 at 00:35