I've installed pyenv
and have different versions of python installed with it:
$ pyenv versions
system
2.7.1
3.2.5
3.5.0
3.5.1
* 3.5.2
I use the following command to switch to python 3.5.2
:
pyenv shell 3.5.2
And when I check the python version this is what I get:
$ python --version
Python 3.5.2
But when I run pytest
, it still runs under python 2.7.6
:
pytest -v
==================================================================== test session starts ====================================================================
platform linux2 -- Python 2.7.6, pytest-3.0.3, py-1.4.31, pluggy-0.4.0 -- /usr/bin/python
Why is pytest
running under the older version?
which python
andwhich pytest
show? Are the pointed-to files links or some launcher scripts? You may also tryhash -r
to eliminate the case of stalebash
path cache. – Lamontwhich python
=>/home/meysam/.pyenv/shims/python
-which pytest
=>/usr/local/bin/pytest
– Mollywhich
out you learn thatpython
uses the python version in your environment, howeverpytest
uses the globally available one, that is located under/usr/local/...
. To run Pytest inside your virtual environment, first install it usingpython -m pip install pytest
and then runpython -m pytest
. – Gwenette