Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test discovery fails on imports for unittest tests in conda environment #20590

Closed
dhowe opened this issue Jan 29, 2023 · 4 comments
Closed

Test discovery fails on imports for unittest tests in conda environment #20590

dhowe opened this issue Jan 29, 2023 · 4 comments
Assignees
Labels
area-testing info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team

Comments

@dhowe
Copy link

dhowe commented Jan 29, 2023

Type: Bug

Steps to reproduce:

  1. Open vscode from a conda environment with a unittest test file that has imports
  2. Notice that tests run from the terminal, as well as via the python-run menu
  3. Notice that test discovery fails (error msg in output section below) when trying to resolve imports in the conda env

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.8
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel
Experiment 'pythonaacf' is active
Experiment 'pythonSurveyNotificationcf' is active
LSP Notebooks experiment is enabled
LSP Notebooks interactive window support is enabled
> conda info --json
Python interpreter path: /usr/local/anaconda3/envs/beetle/bin/python
> conda run -n beetle --no-capture-output python ~/.vscode/extensions/ms-python.python-2022.20.2/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.20.2/pythonFiles/printEnvVariables.py
> /usr/local/anaconda3/bin/python ~/.vscode/extensions/ms-python.python-2022.20.2/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.20.2/pythonFiles/interpreterInfo.py
> /usr/local/anaconda3/envs/beetle/bin/python ~/.vscode/extensions/ms-python.python-2022.20.2/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.20.2/pythonFiles/interpreterInfo.py
Starting Pylance language server.
> conda run -n beetle --no-capture-output python ~/.vscode/extensions/ms-python.python-2022.20.2/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.20.2/pythonFiles/printEnvVariables.py
> conda run -n beetle --no-capture-output python ~/.vscode/extensions/ms-python.python-2022.20.2/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.20.2/pythonFiles/testing_tools/unittest_discovery.py ./back-end test_*.py
cwd: .
[ERROR 2023-0-28 23:17:27.686]: Error discovering unittest tests:
 Failed to import test module: test_prompts
Traceback (most recent call last):
  File "/usr/local/Cellar/[email protected]/3.11.1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/unittest/loader.py", line 407, in _find_test_path
    module = self._get_module_from_name(name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/unittest/loader.py", line 350, in _get_module_from_name
    __import__(name)
  File "/Users/dhowe/git/Beetlemania/back-end/test_prompts.py", line 6, in <module>
    from language_api import LanguageModel
  File "/Users/dhowe/git/Beetlemania/back-end/language_api.py", line 1, in <module>
    import openai
ModuleNotFoundError: No module named 'openai'

XXX

User Settings


languageServer: "Pylance"

formatting
• provider: "black"
• blackPath: "<placeholder>"

testing
• unittestArgs: "<placeholder>"
• unittestEnabled: true

Extension version: 2022.20.2
VS Code version: Code 1.74.3 (Universal) (97dec172d3256f8ca4bfb2143f3f76b503ca0534, 2023-01-09T17:07:18.579Z)
OS version: Darwin x64 20.6.0
Modes:
Sandboxed: No

System Info
Item Value
CPUs Intel(R) Core(TM) i7-1060NG7 CPU @ 1.20GHz (8 x 1200)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) 4, 7, 6
Memory (System) 16.00GB (0.31GB free)
Process Argv . --crash-reporter-id 95b4ae04-b221-4f99-8b7e-05ee427b1ff8
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscoreces:30445986
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593cf:30376535
pythonvs932:30410667
cppdebug:30492333
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
azure-dev_surveyone:30548225
vscccc:30610679
pyindex848:30577860
nodejswelcome1cf:30587006
3biah626:30602489
89544117:30613380
2i9eh265:30646982

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Jan 29, 2023
@eleanorjboyd
Copy link
Member

eleanorjboyd commented Jan 30, 2023

Hello! Could you send all the environment variables that are in your environment? You can just do env or printenv from the command line. Thanks!

@eleanorjboyd eleanorjboyd added the info-needed Issue requires more information from poster label Jan 30, 2023
@dhowe
Copy link
Author

dhowe commented Feb 1, 2023

I'd rather not do that for the obvious reasons. But here are the python-related items (output from within the conda env 'beetle'):


CONDA_EXE=/usr/local/anaconda3/bin/conda
CONDA_PREFIX=/usr/local/anaconda3/envs/beetle
CONDA_PROMPT_MODIFIER=(beetle) 
_CE_CONDA=
CONDA_SHLVL=2
CONDA_PYTHON_EXE=/usr/local/anaconda3/bin/python
CONDA_DEFAULT_ENV=beetle
CONDA_PREFIX_1=/usr/local/anaconda3
PATH=/usr/local/anaconda3/envs/beetle/bin:/usr/local/anaconda3/condabin:/usr/local/bin/python3.11:...

@karthiknadig
Copy link
Member

Can you try this in the terminal?

conda run -n beetle --no-capture-output python -c "import openai"

I am suspecting something is going wrong with using conda run

@brettcannon
Copy link
Member

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.

@brettcannon brettcannon closed this as not planned Won't fix, can't repro, duplicate, stale Mar 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

4 participants