py.test: ImportError: No module named mysql
mysql, pytest, python, virtualenv
Solution
It seems like you're using system-wide version of `py.test` which use non-virtualenv-version of python. (In which, `mysql` package is not installed).
Install `py.test` inside the virtualenv, then your problem will be solved.
SIDE NOTE
To make sure you're using the newly-installed `py.test`, clear the command path cache used by shell.
For example, if you use `bash`, issue the following command:
hash -r
Problem
I have problems running py.test over packages that imports mysql. The package mysql was installed with pip in a virtualenv. ``` # test_mysql.py import mysql def foo(): pass ``` I can run without any problem `python test_mysql.py`, but when I execute `py.test test_mysql.py` I get: ``` > import mysql E ImportError: No module named mysql ``` Any idea what's the problem?