Sublime Text build system from conda environment: Numpy "DLL load failed: The specified module could not be found"
See original GitHub issueWhen using the numpy package in a python script ran within sublime text I get the error “DLL load failed: The specified module could not be found”.
I already tried reinstalling numpy using conda, but to no avail.
I established different “build systems” within sublime text to run the python code (extremely basic test code, see below). The build systems use python executable files: “C:/Users/Sjoerd/Miniconda3/envs/DevPython37/python”, where DevPython37 is my user defined name of the conda environment related to the python version I want to use. I have one environment with Python 3.7 and one with 2.7. The error occurs with both environments.
When starting sublime text from the anaconda prompt this error does not occur. Also when I start jupyter notebook from the anaconda prompt and use numpy in the jupyter notebook, numpy also works fine. However, I would like it to work when I start up sublime text from any location and not just when using the terminal. I hope someone is able to help me resolve this issue.
There is some (to me seemingly) similar issue relating to PyCharm (https://github.com/ContinuumIO/anaconda-issues/issues/1508#issuecomment-446339859). This is how I figured out it works when opening sublime text from the terminal.
System specifications:
I use Windows 10 on a 64-bit machine. Python version: error occurs with both the Python3.7 (with numpy 1.16.5) build system and the Python2.7 (with numpy 1.16.5) build system. Conda version 4.7.12 (installed through Miniconda3)
Reproducing code example:
Test code that raises the numpy error
import time
import numpy as np
for i in range(5):
print ("hello world...")
time.sleep(1)
A = np.array([1,2,3])
print A
(NOTE: with python3.7 the syntax of print is adapted to print(A))
The code to establish the build system (“.sublime-build” file, located at “C:\Users\Sjoerd\AppData\Roaming\Sublime Text 3\Packages\User”). python2.7 case is similar.
{
"cmd": ["C:/Users/Sjoerd/Miniconda3/envs/DevPython37/python", "-u", "$file"],
"selector": "source.python",
"file_regex": "^\\s*File \"(...*?)\", line ([0-9]*)"
}
Error message:
ERROR MESSAGE WHEN USING PYTHON27 BUILD SYSTEM:
Traceback (most recent call last):
File "C:\Users\Sjoerd\Documents\Python_Projects\Hello_world_test.py", line 2, in <module>
import numpy as np
File "C:\Users\Sjoerd\Miniconda3\envs\DevPython27\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import core
File "C:\Users\Sjoerd\Miniconda3\envs\DevPython27\lib\site-packages\numpy\core\__init__.py", line 71, in <module>
raise ImportError(msg)
ERROR MESSAGE WHEN USING PYTHON37 BUILD SYSTEM:
Traceback (most recent call last):
File "C:\Users\Sjoerd\Documents\Python_Projects\Hello_world_test.py", line 3, in <module>
import numpy as np
File "C:\Users\Sjoerd\Miniconda3\envs\DevPython37\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\Users\Sjoerd\Miniconda3\envs\DevPython37\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.
Issue Analytics
- State:
- Created 4 years ago
- Comments:20 (6 by maintainers)
Hello, after struggling a lot and almost giving up, I found the solution !!! Step 1. Follow these instructions. Step 2. Press Ctrl+Shift+P and select Conda:Activate Environment. Step 3. Import numpy and cry from happiness. Happy coding !
Currently crying from happiness. Thanks a lot Olivezer, this worked for me:). To me this seems like a very elegant solution.