Importing the numpy c-extensions failed
Try to uninstall numpy and setuptools first:
pip uninstall -y numpy
pip uninstall -y setuptools
pip install setuptools
pip install numpy
Borrowed from solution provided by mehdiHadji here- https://github.com/ipython/ipyparallel/issues/349
Not sure this is a thing in Visual Studio too, but for Eclipse I had to change one of the environmental variables.
Setup: Windows, Python 3.7, Conda venv with numpy
Solution:
CONDA_DLL_SEARCH_MODIFICATION_ENABLE=1
For Eclipse, the environment variables can be accessed via Properties -> Run/Debug Settings -> Edit -> Environment.
Anaconda also documented the fix, albeit for a different problem:Conda Troubleshooting
This issue is caused by VScode default terminal (powershell) setting,To switch VScode default terminal from powershell to cmd, the conda env will be activated correctly, other powershell will try to invoke conda activate xxxxxx
which will fail, then the subsequent import numpy
will fail.
So two ways to fix it:
Fix path search issue under powershell environment to get
conda activate xxxxxx
successfully executed;Change vs code default terminal to 'cmd':add "terminal.integrated.shell.windows": "C:\Windows\System32\cmd.exe" in settings.json