Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flake8 uses system python instead of virtualenv

My flake8 is giving different outputs to a colleague's, and the difference seems to be in the python version:

(hydro2) andrew@xxx $ flake8 --version
3.5.0 (mccabe: 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.6.0) CPython 2.7.12 on Linux

Whereas on his machine it says CPython 3.5.0 or so.

I'm running the flake8 installed inside a python 3.5 virtualenv, and everything seems to point to the right place:

(hydro2) andrew@xxx $ which python
/home/andrew/virtualenvs/hydro2/bin/python
(hydro2) andrew@xxx $ python --version
Python 3.5.2
(hydro2) andrew@xxx $ which flake8
/home/andrew/virtualenvs/hydro2/bin/flake8

So I'm just confused as to why it's using CPython 2.7.12 (which is my OS's default) instead of the virtualenv's version?

I have tried uninstalling and reinstalling flake8 in the virtualenv.

like image 902
andyhasit Avatar asked Aug 14 '26 07:08

andyhasit


1 Answers

To run a command line tool from a virtual environment you use python -m

Therefore, to run flake8 from your virtual environment:

python -m flake8

This assumes that you activated your virtual environment.

like image 158
ReenigneArcher Avatar answered Aug 16 '26 20:08

ReenigneArcher