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.

Environments needs to be activated before running code on the user's behalf (e.g. unit tests or DS)

See original GitHub issue

Environment data

  • VS Code version: 1.29.0
  • Extension version (available under the Extensions sidebar): 2018.10.1
  • OS and version: Windows10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.1 (Anaconda) and 3.6.7 (Anaconda)
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda-4.5.11
  • Relevant/affected Python packages and their versions: numpy-1.15.3, pytest-3.10, nose-1.3.7

Related Issues:

Actual behavior

Tests are discovered and run in Python-3.6 conda env, but not in Python-3.7, which doesn’t discover tests and/or fails in conftests.py when importing numpy, fails to load DLL multiarray. But numpy does work in a terminal, when py37 is activated, and I can import multiarray from numpy.core.

Also I can even run pytest directly from the terminal inside vscode, so it’s something specific to how the tests are implemented. Maybe it’s not implementing the conda environment correctly?

Same issue with both pytest and nosetests.

Expected behavior

discover and run tests in Python-3.7 same as in Python-3.6

Steps to reproduce:

  1. install anaconda
  2. create py3.6 and py3.7 environments
  3. install vscode, python extension
  4. open a python project with testing (that uses numpy?), enable testing, select each environment and run tests.

Logs

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

here’s the output from pytest:

============================= test session starts =============================
platform win32 -- Python 3.7.1, pytest-3.10.0, py-1.7.0, pluggy-0.8.0
rootdir: c:\Users\mikm\Projects\pvlib-python, inifile:
collected 0 items / 1 errors

=================================== ERRORS ====================================
______________________________ ERROR collecting  ______________________________
..\..\AppData\Local\Continuum\miniconda3\envs\py37\lib\site-packages\_pytest\config\__init__.py:429: in _importconftest
    return self._conftestpath2mod[conftestpath]
E   KeyError: local('c:\\Users\\mikm\\Projects\\pvlib-python\\pvlib\\test\\conftest.py')

During handling of the above exception, another exception occurred:
..\..\AppData\Local\Continuum\miniconda3\envs\py37\lib\site-packages\numpy\core\__init__.py:16: in <module>
    from . import multiarray
E   ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:
..\..\AppData\Local\Continuum\miniconda3\envs\py37\lib\site-packages\_pytest\config\__init__.py:435: in _importconftest
    mod = conftestpath.pyimport()
..\..\AppData\Local\Continuum\miniconda3\envs\py37\lib\site-packages\py\_path\local.py:668: in pyimport
    __import__(modname)
..\..\AppData\Local\Continuum\miniconda3\envs\py37\lib\site-packages\_pytest\assertion\rewrite.py:294: in load_module
    six.exec_(co, mod.__dict__)
pvlib\test\conftest.py:3: in <module>
    import numpy as np
..\..\AppData\Local\Continuum\miniconda3\envs\py37\lib\site-packages\numpy\__init__.py:142: in <module>
    from . import add_newdocs
..\..\AppData\Local\Continuum\miniconda3\envs\py37\lib\site-packages\numpy\add_newdocs.py:13: in <module>
    from numpy.lib import add_newdoc
..\..\AppData\Local\Continuum\miniconda3\envs\py37\lib\site-packages\numpy\lib\__init__.py:8: in <module>
    from .type_check import *
..\..\AppData\Local\Continuum\miniconda3\envs\py37\lib\site-packages\numpy\lib\type_check.py:11: in <module>
    import numpy.core.numeric as _nx
..\..\AppData\Local\Continuum\miniconda3\envs\py37\lib\site-packages\numpy\core\__init__.py:26: in <module>
    raise ImportError(msg)
E   ImportError: 
E   Importing the multiarray numpy extension module failed.  Most
E   likely you are trying to import a failed build of numpy.
E   If you're working with a numpy git repo, try `git clean -xdf` (removes all
E   files not under version control).  Otherwise reinstall numpy.
E   
E   Original error was: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:
..\..\AppData\Local\Continuum\miniconda3\envs\py37\lib\site-packages\py\_path\common.py:377: in visit
    for x in Visitor(fil, rec, ignore, bf, sort).gen(self):
..\..\AppData\Local\Continuum\miniconda3\envs\py37\lib\site-packages\py\_path\common.py:429: in gen
    for p in self.gen(subdir):
..\..\AppData\Local\Continuum\miniconda3\envs\py37\lib\site-packages\py\_path\common.py:418: in gen
    dirs = self.optsort([p for p in entries
..\..\AppData\Local\Continuum\miniconda3\envs\py37\lib\site-packages\py\_path\common.py:419: in <listcomp>
    if p.check(dir=1) and (rec is None or rec(p))])
..\..\AppData\Local\Continuum\miniconda3\envs\py37\lib\site-packages\_pytest\main.py:599: in _recurse
    ihook = self.gethookproxy(dirpath)
..\..\AppData\Local\Continuum\miniconda3\envs\py37\lib\site-packages\_pytest\main.py:417: in gethookproxy
    my_conftestmodules = pm._getconftestmodules(fspath)
..\..\AppData\Local\Continuum\miniconda3\envs\py37\lib\site-packages\_pytest\config\__init__.py:413: in _getconftestmodules
    mod = self._importconftest(conftestpath)
..\..\AppData\Local\Continuum\miniconda3\envs\py37\lib\site-packages\_pytest\config\__init__.py:452: in _importconftest
    raise ConftestImportFailure(conftestpath, sys.exc_info())
E   _pytest.config.ConftestImportFailure: (local('c:\\Users\\mikm\\Projects\\pvlib-python\\pvlib\\test\\conftest.py'), (<class 'ImportError'>, ImportError("\nImporting the multiarray numpy extension module failed.  Most\nlikely you are trying to import a failed build of numpy.\nIf you're working with a numpy git repo, try `git clean -xdf` (removes all\nfiles not under version control).  Otherwise reinstall numpy.\n\nOriginal error was: DLL load failed: The specified module could not be found.\n"), <traceback object at 0x0000012E97C8C688>))
 generated xml file: C:\Users\mikm\AppData\Local\Temp\tmp-18512deYtowEyIRt8.xml 
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!
=========================== 1 error in 0.53 seconds ===========================

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

There were some errors in discovering unit tests

t.onDidNotificationChange @ notificationsAlerts.ts:40
(anonymous) @ notificationsAlerts.ts:26
e.fire @ event.ts:145
t.notify @ notifications.ts:113
t.notify @ notificationService.ts:52
e._showMessage @ mainThreadMessageService.ts:83
e._showMessage @ mainThreadMessageService.ts:44
e.$showMessage @ mainThreadMessageService.ts:38
t._doInvokeHandler @ rpcProtocol.ts:439
t._invokeHandler @ rpcProtocol.ts:424
t._receiveRequest @ rpcProtocol.ts:341
t._receiveOneMessage @ rpcProtocol.ts:271
(anonymous) @ rpcProtocol.ts:146
e.fire @ event.ts:145
a @ ipc.net.ts:103
n._socketDataListener @ ipc.net.ts:132
emitOne @ events.js:116
emit @ events.js:211
addChunk @ _stream_readable.js:263
readableAddChunk @ _stream_readable.js:250
Readable.push @ _stream_readable.js:208
onread @ net.js:594

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

8reactions
brettcannoncommented, Nov 21, 2018

Just so people know, we’re trying to schedule a meeting with Anaconda to figure out how best to handle this. Once we have that meeting we will be in a better place to know how to solve this going forward.

3reactions
gvellutcommented, Nov 21, 2018

I had the same issue. Until it is fixed, I created a batch file :

@echo off
C:\\Users\\gvellut\\Anaconda3\\Scripts\\activate.bat wbt2 && pytest %*

And configured the “python.unitTest.pyTestPath” option to launch it (instead of pytest directly).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Activate Unit Test in Development and Test Phase and not ...
Is it possible to activate the unit testing in development and test phase and not in production phase? Info: *Source code is taken...
Read more >
Getting Integration Testing Right - Semaphore CI
Tools, libraries, and CI/CD environments can make integration testing as straightforward as unit testing! How is this possible, you ask?
Read more >
Testing electronic health records in the “production” environment
Thorough and ongoing testing of electronic health records (EHRs) is key to ensuring their safety and effectiveness. Many health care organizations limit ...
Read more >
Installation, Back-out, and Rollback Guide Template - Veterans Affairs
April 25, 2022, 8.0, Added steps for activating the wave 1 2022 update, TMP Dev Team. Jan 11, 2021, 7.0, Added URL to...
Read more >
Item 30: Write more than unit tests - Effective Rust
The most common form of test for Rust code is a unit test, ... In line with Item 18, you should set a...
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