Note that there are some explanatory texts on larger screens.

plurals
  1. POvirtualenv and subprocess.call() in mixed Python 2.7/3.3 environment
    primarykey
    data
    text
    <p>For some functional tests, I invoke a couple of utilities directly from the project directory, using Python's <code>subprocess.call</code> (or <code>check_call</code> which invokes the latter). This works well when the libraries (PyYAML in particular) are installed globally. Running in a virtualenv, such as under Travis-CI, causes problems, especially if the virtualenv is running Python 3.x and the global Python is 2.7.</p> <p>If both Pythons are 2.7, I still had to inject the location of PyYAML within the virtualenv, using the <code>env</code> argument to <code>subprocess.call</code>, in order not to cause an ImportError. However, this doesn't work when the virtualenv is 3.x. It appears the invoked utility runs outside the virtualenv because its <code>sys.path</code> looks as follows:</p> <pre><code> '/home/travis/build/jmafc/Pyrseas/pyrseas', '/usr/local/lib/python2.7/dist-packages/distribute-0.6.35-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/pip-1.3.1-py2.7.egg', '/home/travis/build/jmafc/Pyrseas', '/home/travis/virtualenv/python3.3/lib/python3.3/site-packages', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg-info', '/usr/lib/python2.7/dist-packages'] </code></pre> <p>Notice the mixture of 2.7 and 3.3 paths, the latter being expressly injected as mentioned above.</p> <p>Is there some way from either <code>virtualenv</code> or in the <code>subprocess</code> functions to ensure the subprocess runs "within" the virtualenv?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload