my python code works in spyder, but errors when run in cmd:
C:\Users\XYZ\AppData\Local\Continuum\anaconda3>python.exe "C:\\Users\\XYZ\\project_1\\Model\\PPP_2_main.py"
Traceback (most recent call last):
File "C:\\Users\\XYZ\\project_1\\Model\\PPP_2_main.py", line 8,
in <module>
import numpy as np
File "C:\Users\XYZ\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\Users\XYZ\AppData\Local\Continuum\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 read this and it says python can't locate the module, and we need to add sys path. But isn't the error msg mentioning the correct path to the numpy library?
Confirm the path to library is correct (in sypder):
import numpy
numpy.__file__
Out[5]: 'C:\\Users\\XYZ\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\numpy\\__init__.py'
Check conda env:
(base) C:\Users\XYZ>conda env list
# conda environments:
#
base * C:\Users\XYZ\AppData\Local\Continuum\anaconda3
The path of the base env is where i was when running the code in cmd
I read this and tried to activate conda, and it didn't work. In conda cmd:
(base) C:\Users\zhayuji>conda activate base
(base) C:\Users\zhayuji\AppData\Local\Continuum\anaconda3>conda activate base
(base) C:\Users\zhayuji\AppData\Local\Continuum\anaconda3>conda list
# packages in environment at C:\Users\zhayuji\AppData\Local\Continuum\anaconda3:
#
# Name Version Build Channel
_ipyw_jlab_nb_ext_conf 0.1.0 py37_0
_py-xgboost-mutex 2.0 cpu_0
alabaster 0.7.12 py37_0
anaconda-client 1.7.2 py37_0
anaconda-navigator 1.9.7 py37_0 anaconda
....
numpy 1.16.2 py37h19fb1c0_0
numpy-base 1.16.2 py37hc3f5095_0
numpydoc 0.9.1 py_0
After this i reopen cmd and ran python code, and it's the same err as at the beginning of the post.