Activate environment before debugging tests
See original GitHub issue- VS Code version: 1.30.2
- Extension version (available under the Extensions sidebar): 2019.1.0
- OS and version: Windows 7
- Python version (& distribution if applicable, e.g. Anaconda): Python 3.7.1, anaconda
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
- Relevant/affected Python packages and their versions: numpy
Expected behaviour
Test runs in debug mode
Actual behaviour
When “Debug Test” is selected from within the editor above a unittest the known error message from #3330 is shown
Steps to reproduce:
- install anaconda
- create py3.6 and py3.7 environments
- install vscode, python extension
- open a folder of a python project using numpy with testing, enable testing, select the environment and click “Debug Test” above a test method of a test case from within the editor.
Logs
============================= test session starts =============================
platform win32 -- Python 3.7.1, pytest-4.2.0, py-1.7.0, pluggy-0.8.1
benchmark: 3.2.2 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: c:\project, inifile:
plugins: cov-2.6.1, benchmark-3.2.2
=================================== ERRORS ====================================
__________________ ERROR collecting tests/test_data_prep.py ___________________
ImportError while importing test module 'c:\project\tests\test_data_prep.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\Users\XXXXX\AppData\Local\Continuum\anaconda3\envs\project\lib\site-packages\numpy\core\__init__.py:16: in <module>
from . import multiarray
E ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
During handling of the above exception, another exception occurred:
tests\test_data_prep.py:1: in <module>
import numpy as np
C:\Users\XXXXX\AppData\Local\Continuum\anaconda3\envs\project\lib\site-packages\numpy\__init__.py:142: in <module>
from . import add_newdocs
C:\Users\XXXXX\AppData\Local\Continuum\anaconda3\envs\project\lib\site-packages\numpy\add_newdocs.py:13: in <module>
from numpy.lib import add_newdoc
C:\Users\XXXXX\AppData\Local\Continuum\anaconda3\envs\project\lib\site-packages\numpy\lib\__init__.py:8: in <module>
from .type_check import ...
generated xml file: C:\Users\XXXXX\AppData\Local\Temp\tmp-10040Ua1sUDOhID1o.xml
=========================== 1 error in 0.27 seconds ===========================
ERROR: not found: c:\project\tests\test_data_prep.py::TestCustomFeautures::test_compare_name_email
(no name 'c:\\project\\tests\\test_data_prep.py::TestCustomFeautures::test_compare_name_email' in any of [<Module test_data_prep.py>])
Issue Analytics
- State:
- Created 5 years ago
- Reactions:53
- Comments:53
Top Results From Across the Web
How do I activate my conda environment for VS Code python ...
Activate the conda environment. You could use shortcut keys directly: Ctrl+Shift+`. enter image description here. When debugging the code, ...
Read more >Using Python environments in VS Code
To select a specific environment, use the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P).
Read more >PyCharm - Run/Debug Configuration: Python Unit Test
Before launch · If the Check errors checkbox is selected, the compiler will show all the errors and the run configuration will not...
Read more >Debug Python code - Visual Studio (Windows) - Microsoft Learn
A debugging session starts with the Debug > Start Debugging command, the Start button on the toolbar, or the F5 key. These actions...
Read more >Advanced Visual Studio Code for Python Developers
Visual Studio Code will activate any Python virtual environment once the interpreter is ... You also have menu buttons that let you run...
Read more >Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s ridiculous that this is still not fixed after 1.5 years. I just spent an hour to find out that this is an open bug. Conda users are completely ignored here. This problem can easily be reproduced. Looks like I have to switch the editor which really is a pitty. I was hoping that things would improve now that this extension was officially taken over by Microsoft but does not look like.
This bug is still an issue for me, and I have not been able to find a good work-around.