question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sublime Text build system from conda environment: Numpy "DLL load failed: The specified module could not be found"

See original GitHub issue

When 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:closed
  • Created 4 years ago
  • Comments:20 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
Olivezercommented, Feb 20, 2020

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 !

3reactions
sjoerdloenencommented, Mar 4, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Numpy ImportError using Sublime Text with Anaconda
import numpy as np ImportError: DLL load failed: The specified module can not be found. I expect to import the module correctly, but...
Read more >
Unable to use numpy in sublime text 3 in Ubuntu - Super User
If not installed, try to install anaconda; On Sublime text, go to Tools->Build System , and select Automatic. Sublime text will ...
Read more >
Getting ArcPy to work with Anaconda? - GIS Stack Exchange
This tutorial shows you how to set up conda environment to work with ArcGIS 10.4 and ArcGIS Pro 1.3. Workflow to set up...
Read more >
How to fix “ImportError: DLL load failed: The specified module ...
If this is a general error in everything you try to do, then Quora User nailed the answer. Just add the Python base...
Read more >
3rd Party Modules not Working with REPL - Sublime Forum
Using Anaconda 3.6. Numpy and Pandas not importing. Able to import with command prompt. Likely screwed up all my settings trying to make ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found