J. Dionisio
J. Dionisio

Reputation: 170

Import Error when using VSCode with conda interpreter but not when importing in Conda

I'm trying to run a Python program in VSCode and it always stops in the first line

from sklearn.gaussian_process.kernels import WhiteKernel, RationalQuadratic, RBF, Matern, ExpSineSquared

The error it gives me is pretty big, I'll paste it at the end.

However, when when I open python in my conda terminal, I can import with no issues at all. Since I'm using the conda interpreter in VSCode, I don't understand what the issue is.

My Python version is 3.7.6, numpy 1.19.1, scipy 1.5.2, sklearn 0.23.2 and am working with Windows 10. I have already tried what the webpage mentioned suggested. And on the bottom left of VSCode it says that the interpreter is Python 3.7.6 64-bit ('base':conda).

Just tried, and I can't import numpy either, but can in conda with no problems. The python versions are the same. EDIT: The error message here asks me to be sure that the Numpy version is 1.18.1, instead of 1.19.1.

Exception has occurred: 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:

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

Original error was: DLL load failed: The specified module could not be found. File "C:\Users\jdion\OneDrive\Ambiente de Trabalho\Tese\Code\The Sea Exploration Problem _aux.py", line 13, in from sklearn.gaussian_process.kernels import WhiteKernel, RationalQuadratic, RBF, Matern, ExpSineSquared

Upvotes: 1

Views: 1529

Answers (1)

J. Dionisio
J. Dionisio

Reputation: 170

I uninstalled both conda and all my Python versions and when I reinstalled Python 3.7.9 and selected it as the interpreter in VSCode there were no more issues. I think the problem was having too many Python versions, anaconda, pip, and I was probably installing and removing things in the wrong places.

Upvotes: 1

Related Questions