-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Environments needs to be activated before running code on the user's behalf (e.g. unit tests or DS) #3330
Comments
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:
|
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 has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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). |
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. |
We'll need to check the performance before committing this change. |
Findings, running Proposed Solution:
|
@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). |
I validated this. |
yay! thanks so much everyone! |
Is this issue solved now? I have the latest version of Anaconda and VS code and I still have this problem. |
@abarajithan11 yes, it's resolved. If you're having issues then please open a new issue. |
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
)The text was updated successfully, but these errors were encountered: