0

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?

3 Answers 3

4

The problem isn't pip or flake8, it's your PATH variable. What you need to do is python -m flake8 to get it to use the one in your environment.

1

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.

5
  • No good. -e is looking for a repository and exits with an error. Without -e, it's the exact same as installing with pip install flake8. Oct 27, 2016 at 14:52
  • Maybe try to use pip3 install
    – Aurous
    Oct 27, 2016 at 14:58
  • I am doing; I'm in a python3 virtual env, so pip3 is the same as pip. Oct 27, 2016 at 15:09
  • that's really strange then, the wheel file should install it as 3.0.4 for the version with it working in python 3. Maybe try: python -m pip install SomePackage
    – Aurous
    Oct 27, 2016 at 16:32
  • 1
    Bizarrely, today, it does work. Perhaps there was something hanging around in that terminal window that was causing it to use system python for whatever reason? Oct 28, 2016 at 10:30
-1

Use pip3 install for Python 3.x

1
  • 1
    This was already suggested, and wasn't the issue, as in a python3 virtual env, pip3 and pip are equivalent. Oct 31, 2016 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.