Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

py.test: ImportError: No module named mysql

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?

like image 837
memecs Avatar asked Feb 15 '14 16:02

memecs


1 Answers

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
like image 81
falsetru Avatar answered Oct 22 '22 21:10

falsetru