Skip to content

Instantly share code, notes, and snippets.

@snim2 snim2/
Created Jun 18, 2015

What would you like to do?
py.test error
$ py.test --version
This is pytest version 2.6.3, imported from /usr/lib/python2.7/dist-packages/pytest.pyc
snim2:2073(0):pydgin$ pip install --user -r requirements.txt
Downloading/unpacking pytest-cov (from -r requirements.txt (line 1))
Downloading pytest-cov-1.8.1.tar.gz
Running (path:/tmp/pip-build-ND85Ym/pytest-cov/ egg_info for package pytest-cov
Downloading/unpacking pytest-xdist (from -r requirements.txt (line 2))
Downloading pytest-xdist-1.12.tar.gz
Running (path:/tmp/pip-build-ND85Ym/pytest-xdist/ egg_info for package pytest-xdist
no previously-included directories found matching '.hg'
Downloading/unpacking py>=1.4.22 (from pytest-cov->-r requirements.txt (line 1))
Downloading py-1.4.28-py2.py3-none-any.whl (81kB): 81kB downloaded
Downloading/unpacking pytest>=2.6.0 (from pytest-cov->-r requirements.txt (line 1))
Downloading pytest-2.7.1-py2.py3-none-any.whl (126kB): 126kB downloaded
Downloading/unpacking coverage<4.0a1,>=3.7.1 (from pytest-cov->-r requirements.txt (line 1))
Downloading coverage-3.7.1.tar.gz (284kB): 284kB downloaded
Running (path:/tmp/pip-build-ND85Ym/coverage/ egg_info for package coverage
warning: no previously-included files matching '*.pyc' found anywhere in distribution
Downloading/unpacking cov-core>=1.14.0 (from pytest-cov->-r requirements.txt (line 1))
Downloading cov-core-1.15.0.tar.gz
Running (path:/tmp/pip-build-ND85Ym/cov-core/ egg_info for package cov-core
Downloading/unpacking execnet>=1.1 (from pytest-xdist->-r requirements.txt (line 2))
Downloading execnet-1.3.0-py2.py3-none-any.whl
Installing collected packages: pytest-cov, pytest-xdist, py, pytest, coverage, cov-core, execnet
Running install for pytest-cov
Running install for pytest-xdist
no previously-included directories found matching '.hg'
Running install for coverage
building 'coverage.tracer' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c coverage/tracer.c -o build/temp.linux-x86_64-2.7/coverage/tracer.o
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/coverage/tracer.o -o build/lib.linux-x86_64-2.7/coverage/
warning: no previously-included files matching '*.pyc' found anywhere in distribution
Installing coverage2 script to /home/snim2/.local/bin
Installing coverage-2.7 script to /home/snim2/.local/bin
Installing coverage script to /home/snim2/.local/bin
Running install for cov-core
Wrote pth file for subprocess measurement to /home/snim2/.local/lib/python2.7/site-packages/init_cov_core.pth
Successfully installed pytest-cov pytest-xdist py pytest coverage cov-core execnet
Cleaning up...
$ py.test --version
Traceback (most recent call last):
File "/usr/bin/py.test", line 5, in <module>
sys.exit(load_entry_point('pytest==2.6.3', 'console_scripts', 'py.test')())
File "/usr/lib/python2.7/dist-packages/pkg_resources/", line 521, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources/", line 514, in get_distribution
dist = get_provider(dist)
File "/usr/lib/python2.7/dist-packages/pkg_resources/", line 394, in get_provider
return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
File "/usr/lib/python2.7/dist-packages/pkg_resources/", line 674, in find
raise VersionConflict(dist, req)
pkg_resources.VersionConflict: (pytest 2.7.1 (/home/snim2/.local/lib/python2.7/site-packages), Requirement.parse('pytest==2.6.3'))

This comment has been minimized.

Copy link

pfctdayelise commented Jun 18, 2015

So your original pytest is installed system wide, but then you're installing another pytest in .local with your pip --user flag. You need /home/$USER/.local/bin in your PATH - ahead of /usr/bin. Then the second pytest you've installed should be picked up first.
Alternatively, run your pip command without --user (and probably need sudo) then everything is system wide.
Or best of all, use virtualenv!
I've typed this on a phone so sorry for typos.


This comment has been minimized.

Copy link
Owner Author

snim2 commented Jun 18, 2015

Thanks. I think I tried apt-get purge python-pytest and installing everything with pip also, and that also failed. It's very confusing having all these different ways of installing things :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.