Environments needs to be activated before running code on the user's behalf (e.g. unit tests or DS)
See original GitHub issueEnvironment 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:
- install anaconda
- create py3.6 and py3.7 environments
- install vscode, python extension
- 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 (View
→Output
, 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:
- Created 5 years ago
- Comments:17 (6 by maintainers)
Top GitHub Comments
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.
I had the same issue. Until it is fixed, I created a batch file :
And configured the “python.unitTest.pyTestPath” option to launch it (instead of pytest directly).