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.

numpy: DLL load failed when running a .py from vscode

See original GitHub issue

Environment data

  • VS Code version: 1.41.1
  • Extension version (available under the Extensions sidebar): 2020.1.58038
  • OS and version: Windows 10 1809 64 bit
  • Python version (& distribution if applicable, e.g. Anaconda): Anaconda 2019.10 (Python 3.7.4, conda 4.8.1)
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
  • Relevant/affected Python packages and their versions: numpy, pandas, matplotlib
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info #3977): true

Expected behaviour

No errors appear. Script is executed successfully.

Actual behaviour

Getting the following error:

Traceback (most recent call last):
  File "o:/cloud/documents/test/test.py", line 3, in <module>
    import pandas as pd
  File "C:\Users\<username>\Anaconda3\lib\site-packages\pandas\__init__.py", line 17, in <module>
    "Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy: DLL load failed: The specified module could not be found.

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Set "python.pythonPath" to "C:\\Users\\<username>\\Anaconda3\\python.exe" in VSCode settings.
  2. Run this script from VSCode by pressing the play button:

import pandas as pd

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)


console.ts:137 [Extension Host] Info Python Extension: 2020-02-01 20:28:51: cwd: o:\cloud\documents\test
console.ts:137 [Extension Host] Info Python Extension: 2020-02-01 20:28:51: > ~\Anaconda3\python.exe -m pylint --disable=all --enable=F,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,unused-wildcard-import,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0107,E0108,E0110,E0111,E0112,E0113,E0114,E0115,E0116,E0117,E0118,E0202,E0203,E0211,E0213,E0236,E0237,E0238,E0239,E0240,E0241,E0301,E0302,E0303,E0401,E0402,E0601,E0602,E0603,E0604,E0611,E0632,E0633,E0701,E0702,E0703,E0704,E0710,E0711,E0712,E1003,E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1136,E1137,E1138,E1139,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1700,E1701 --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text o:\cloud\documents\test\test.py
console.ts:137 [Extension Host] Info Python Extension: 2020-02-01 20:28:51: cwd: o:\cloud\documents\test
console.ts:137 [Extension Host] Info Python Extension: 2020-02-01 20:29:29: Cached data exists getEnvironmentVariables, Untitled-1

Things to note:

  1. The DLL load failed error is not in red, so it’s not necessarily a system error.

  2. Pressing the Play button for the first time with the aforementioned script triggers the following error (in red) when VSCode tries to execute the conda activate base command:

conda : The term 'conda' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try 
again.
At line:1 char:1
+ conda activate base
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (conda:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

However, VSCode executes the following command immediately after: PS C:\Users\<username>> & C:/Users/<username>/Anaconda3/python.exe o:/cloud/documents/test/test.py which is when I get the DLL load failed error (again, not in red).

  1. Pressing the Play button for the first time with a different script (print("Hello World")) still triggers the term is not recognized error (in red) when VSCode tries to execute the conda activate base command. But the PS C:\Users\<username>> & C:/Users/<username>/Anaconda3/python.exe o:/cloud/documents/test/test.py command gets executed (by VSCode) successfully and prints out "Hello world".

  2. All scripts (including ones with numpy imports) run just fine from Anaconda prompt.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
DavidKutucommented, Feb 3, 2020

Hi @github-account1111, I think this might be an issue with Powershell. Could you try changing your default shell in vscode to ‘Command Prompt’ instead of Powershell?

0reactions
github-account1111commented, Feb 6, 2020

Because we need to know how to construct the command to execute on your behalf in the terminal. It has nothing to do with the environment of the terminal.

You are contradicting yourself. First you say all you do is act as a terminal. A terminal doesn’t need those two flags to construct the command to execute on my behalf, but the extension does. What gives?

The fact that conda init broke something is not our doing because it didn’t involve running any of our code; it was all by conda, for conda.

It didn’t break anything. It just didn’t execute. I’ve installed everything correctly (frankly, there isn’t much to mess up, it’s a standard installer). Followed the docs on VSCode’s site and here I am. Can’t do the most basic of tasks - running a script.

everything provided points to your PowerShell and conda environment being the culprit of your issues and not the extension itself

How so? I would say everything points to a disconnect between VSCode’s conda documentation and how conda actually works. Now, you could keep insisting that that isn’t your problem, but the documentation is actually yours, not conda’s.

Conda is pretty popular, either do something about this or be honest and say your extension doesn’t work with Conda.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DLL load failed on Visual Studio Code #16139
VSC runs Python fine, it's just a few libraries that it fails to import--does this still mean the environment is not activated?
Read more >
DLL load failed: The specific module could not be found ...
I had the same issue, I've fixed it by adding the Python.CondaPath in settings. Press Ctrl + Shift + P and select Terminal...
Read more >
DLL load failed on Visual Studio Code - Python/Anaconda
This is my first time using VS Code and it runs python fine, but it is not able to import numpy. I'm using...
Read more >
Import Numpy Package error - Visual Studio Feedback
This is a known issue in numpy when installed into Python 3.6.0 from the public wheels on PyPI. You can work around it...
Read more >
DLL load failed while importing _multiarray_umath: 지정된 ...
Original error was: DLL load failed while importing _multiarray_umath: 지정된 모듈을 찾을 수 없습니다. · 1. 명령 팔레트를 연다 (Ctrl + Shift +...
Read more >

github_iconTop Related Medium Post

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