question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Activate environment before running tests

See original GitHub issue

Environment 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:

  1. Set up virtualenv (python -m virtualenv venv)
  2. Open folder in VS Code and choose Python interpreter to “Python 3.7.0 (venv)”.
  3. I have a nose test which runs pylint command via Popen(..., 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:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
brettcannoncommented, Aug 27, 2018

I’ve re-opened this as a feature request.

0reactions
DonJayamannecommented, Jan 10, 2019

Closed in favor of #3330

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found