Reputation: 55
So I've finished building my new PC, basically a fresh windows install with just some drivers and basic programs. After setting everything up I decided to install Anaconda and VSCode. Thats what I did and that is ALL I installed. I set up environment paths to the python.exe. Despite this when I try to import numpy in VSCode it doesnt work.
I tried running this tiny bit of code to see if VSCode could import conda modules:
import numpy as np
data = [1, 32, 345, 2, 543, 48237, 3, 432, 378, 946, 234, 12, 345, 1, 2, 3, 4567, 32]
print(np.mean(data)
Running the above code resulted in this error:
Traceback (most recent call last):
File "c:\Users\Daniel\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\ptvsd_launcher.py", line 43, in <module>
main(ptvsdArgs)
File "c:\Users\Daniel\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\lib\python\ptvsd\__main__.py", line 432, in main
run()
File "c:\Users\Daniel\.vscode\extensions\ms-python.python-2019.8.30787\pythonFiles\lib\python\ptvsd\__main__.py", line 316, in run_file
runpy.run_path(target, run_name='__main__')
File "C:\Users\Daniel\Anaconda3\lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "C:\Users\Daniel\Anaconda3\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Users\Daniel\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "c:\dev\test\main.py", line 1, in <module>
import numpy as np
File "C:\Users\Daniel\Anaconda3\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\Users\Daniel\Anaconda3\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.
I tried seeing if Visual Studio Code is using the correct interpreter just in case but just like I expected there is only one interpreter to choose from
EDIT: It does work in command line as expected and I tried doing conda install numpy with no success
EDIT2: Solved! I noticed the following error in my VS Code:
File *name* cannot be loaded because running scripts is disabled on this system.
So I went into powershell and allowed to run signed scripts by typing in 'Set-ExecutionPolicy RemoteSigned' and everything worked like a charm afterwards
Upvotes: 1
Views: 3512
Reputation: 55
Managed to solve this one myself. I noticed the following error in my VS Code:
File *name* cannot be loaded because running scripts is disabled on this system.
So I went into powershell and allowed to run signed scripts by typing in 'Set-ExecutionPolicy RemoteSigned' and everything worked like a charm afterwards
In any case thanks to everyone who tried to help, turns out i have to learn to read
Upvotes: 1