Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upEnvironments needs to be activated before running code on the user's behalf (e.g. unit tests or DS) #3330
Comments
brettcannon
self-assigned this
Nov 15, 2018
brettcannon
added
triage
type-bug
needs PR
feature-testing
and removed
triage
labels
Nov 15, 2018
This comment has been minimized.
This comment has been minimized.
I can discover and run tests fine under conda using Python 3.7 and pytest without numpy, but I do get the same failure if the environment is not activated. It seems conda has chosen to package numpy in such a way that it can't be imported unless the environment is activated (which we don't do when running tests). With a test of: import numpy
def test_fake():
return True and settings of: "python.unitTest.pyTestArgs": [
"."
],
"python.unitTest.unittestEnabled": false,
"python.unitTest.nosetestsEnabled": false,
"python.unitTest.pyTestEnabled": true I end up with:
|
brettcannon
removed their assignment
Nov 15, 2018
brettcannon
referenced this issue
Nov 15, 2018
Closed
VS Code does not properly activate anaconda 5.3 -> Cannot import numpy, DLL not found #3040
This comment has been minimized.
This comment has been minimized.
I also forgot to mention that I verified this in an Anaconda Prompt by running directly the Python interpreter and then indirectly through an activated terminal and got the same results, so it's definitely based on how they have chosen to package numpy for at least Python 3.7. We might have to use |
This comment was marked as resolved.
This comment was marked as resolved.
Although numpy is a stubborn one, with it's BLAS and LAPACK dependencies. Maybe there's more to this? Do you think I should open a conda issue? |
This comment was marked as resolved.
This comment was marked as resolved.
|
This comment was marked as resolved.
This comment was marked as resolved.
|
This comment was marked as resolved.
This comment was marked as resolved.
mingwandroid
commented
Nov 15, 2018
•
This is not a conda bug. The conda package manager allows packages to specify activation and deactivation scripts which, generally speaking must be run for the software to work correctly. These scripts can do arbitrary things, setting env vars, running programs, whatever they need to. Simply put, running any Anaconda Distribution software outside of using the correct activation procedure is not and never will be supported. In this particular instance, it's not actually the problem that the activation scripts are not run, it is the more fundamental fact that conda activation sets People are free to avoid this advice and in many cases everything will be fine, but it's unsupported (and I have no idea why people think avoiding activation would be considered reasonable, to be clear, if activation was optional it wouldn't exist!). Finally please remember AD is about more than just Python too. |
This comment was marked as resolved.
This comment was marked as resolved.
mingwandroid
commented
Nov 15, 2018
This issue should not be closed until it is fixed as per @brettcannon's comments. |
This comment was marked as resolved.
This comment was marked as resolved.
I agree, @mingwandroid, and I'm sorry. I typed too hastily, and I should've thought about it more carefully.
I started to realize this as I was typing, but I should have revised my comments before submitting.
|
DonJayamanne
referenced this issue
Nov 16, 2018
Closed
run cell doesn't work even if jupyter notebook has been installed #3354
This comment has been minimized.
This comment has been minimized.
gvellut
commented
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). |
This comment has been minimized.
This comment has been minimized.
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. |
brettcannon
changed the title
test frameworks fails with python 3.7 from anaconda
when using a conda environment, the environment is not activated when running tests
Nov 21, 2018
brettcannon
added
the
P1
label
Jan 2, 2019
qubitron
changed the title
when using a conda environment, the environment is not activated when running tests
Conda needs to be activated starting with Python 3.7
Jan 2, 2019
This comment has been minimized.
This comment has been minimized.
qubitron
commented
Jan 2, 2019
We'll need to check the performance before committing this change. |
qubitron
changed the title
Conda needs to be activated starting with Python 3.7
Conda needs to be activated before running code on the user's behalf
Jan 2, 2019
DonJayamanne
added this to the 2019, week 1 - Jan Sprint 1 milestone
Jan 2, 2019
DonJayamanne
self-assigned this
Jan 7, 2019
This comment has been minimized.
This comment has been minimized.
DonJayamanne
commented
Jan 7, 2019
Findings, running Proposed Solution:
|
This comment has been minimized.
This comment has been minimized.
@DonJayamanne How does the failure manifest itself? I would be curious to know why it's occurring (if it's because of virtualenv then I can understand that). |
rchiodo
referenced this issue
Jan 8, 2019
Open
Run Cell does not find Jupyter in virtual environment #3537
DonJayamanne
referenced this issue
Jan 8, 2019
Merged
Run python code using env variables from activated envs #3930
DonJayamanne
referenced this issue
Jan 10, 2019
Closed
Interpreter list reporting global interpreters twice & reporting wrong bugfix version #3953
DonJayamanne
changed the title
Conda needs to be activated before running code on the user's behalf
Environments needs to be activated before running code on the user's behalf (e.g. unit tests or DS)
Jan 10, 2019
DonJayamanne
referenced this issue
Jan 10, 2019
Closed
Activate environment before running tests #2420
DonJayamanne
added
the
validate fix
label
Jan 16, 2019
DonJayamanne
modified the milestones:
2019, week 1 - Jan Sprint 1,
2019, week 3 - Jan Sprint 2
Jan 16, 2019
DonJayamanne
assigned
ericsnowcurrently
and unassigned
DonJayamanne
Jan 29, 2019
DonJayamanne
closed this
Jan 29, 2019
pvscbot
removed
needs PR
validate fix
labels
Jan 29, 2019
This comment has been minimized.
This comment has been minimized.
I validated this. |
This comment has been minimized.
This comment has been minimized.
yay! thanks so much everyone! |
mikofski commentedNov 13, 2018
•
edited
Environment data
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 DLLmultiarray
. But numpy does work in a terminal, when py37 is activated, and I can importmultiarray
fromnumpy.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
andnosetests
.Expected behavior
discover and run tests in Python-3.7 same as in Python-3.6
Steps to reproduce:
Logs
Output for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)here's the output from
pytest
:Output from
Console
under theDeveloper Tools
panel (toggle Developer Tools on underHelp
)