Activate environment before running tests
See original GitHub issueEnvironment data
- VS Code version: 1.26.1
- Extension version (available under the Extensions sidebar): 2018.7.1
- OS and version: CentOS Linux release 7.4.1708 (Core)
- Python version (& distribution if applicable, e.g. Anaconda): 3.7.0 (built from source)
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): virtualenv
Steps to reproduce:
- Set up virtualenv (python -m virtualenv venv)
- Open folder in VS Code and choose Python interpreter to “Python 3.7.0 (venv)”.
- I have a nose test which runs
pylint
command viaPopen(..., shell=True)
with plugin in the source code.
Expected behavior
Test runs pylint installed into virtualenv
Actual behavior
Despite that python is taken from virtualenv, test runs with system PATH
variable which does not have installed package (or has wrong version).
Logs
Output from ps -ef | grep python
when running the test:
default 21133 21033 0 12:21 ? 00:00:00 /home/default/conan/venv/bin/python /home/default/.vscode/extensions/ms-python.python-2018.7.1/pythonFiles/jedi/evaluate/compiled/subprocess/__main__.py /home/default/.vscode/extensions/ms-python.python-2018.7.1/pythonFiles
default 24974 20915 39 12:37 ? 00:00:00 /home/default/conan/venv/bin/python -m nose --xunit-file=/tmp/tmp-209153hIDoVKwtMyE.xml --with-xunit --with-id conans/test/command/export_linter_test.py:ExportLinterTest.test_basic conans/test/command/export_linter_test.py:ExportLinterTest.test_basic
default 25008 24974 0 12:37 ? 00:00:00 /opt/rh/rh-python36/root/usr/bin/python3 /usr/bin/pylint --output-format=json --py3k --enable=all --reports=no --disable=no-absolute-import --persistent=no --load-plugins=conans.pylint_plugin --init-hook=import sys;sys.path.extend(['/tmp/tmp81scfb65conans/path with spaces', '/home/default/conan']) /tmp/tmp81scfb65conans/path with spaces/conanfile.py
So it runs /usr/bin/pylint
instead of /home/default/conan/venv/bin/pylint
when VS Code was started from Start Menu.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Activate Unit Test in Development and Test Phase and not ...
Is it possible to activate the unit testing in development and test ... UseEnvironment("Development") // You can set the environment you ...
Read more >Managing environments - Conda
Switching or moving between environments is called activating the environment. ... For conda versions prior to 4.6, run: Windows: activate or deactivate.
Read more >Python Virtual Environments: A Primer
Generally, before you start using it, you'll first activate the environment by executing a script that comes with the installation:.
Read more >How do I activate a virtualenv inside PyCharm's terminal?
To test this, open a new windows terminal (Start --> type in cmd and hit Enter ) and see if it's using your...
Read more >Using Python environments in VS Code
An "environment" in Python is the context in which a Python program runs and ... Once you activate your virtual environment, you'll need...
Read more >Top Related Medium Post
No results found
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
I’ve re-opened this as a feature request.
Closed in favor of #3330