Adam Barnes Adam Barnes - 1 month ago 9
Python Question

pip installing flake8 in a Python3 virtualenv installs flake8 for python 2.7 on OSX

I'm trying to set atom up correctly, and the

linter-flake8
package is annoying me by pointing out syntax errors which aren't there, because it's using a python 2 flake8.

Doubly annoying is that when such an error is pointed out in a file, the rest of the file isn't linted, making finding unused imports that much harder.

I set the executable path in the settings to point to the right binary after pip installing it, but the same errors occur.

$ which python
/Users/asday/.virtualenvs/_/bin/python
$ which pip
/Users/asday/.virtualenvs/_/bin/pip
$ pip install flake8
[...]
$ which flake8
/Users/asday/.virtualenvs/_/bin/flake8
$ python -V
Python 3.5.1
$ pip -V
pip 8.1.2 from /Users/asday/.virtualenvs/_/lib/python3.5/site-packages (python 3.5)
$ flake8 --version
2.5.4 (pep8: 1.7.0, pyflakes: 1.0.0, mccabe: 0.4.0) CPython 2.7.11 on Darwin
$ flake8 .
./test.py:9:14: E901 SyntaxError: invalid syntax


Where test.py is simply:

def f(*args, **kwargs):
pass


kwargs = {}

f(
a=1,
**kwargs,
)


How do I get flake8 to install with the right version of python on OSX?

Answer

You could download the flake 8 project from https://pypi.python.org/pypi/flake8 then use

pip install file.whl
This way you can just install it from your local python and it should install as python 3.

Comments