1

I was reading the documentation for flake8 and saw that it can be invoked specifying the python version. I would like to be able to do both 2.7 and 3+. When I attempt 3, it works just fine, but when I do 2.7 I get an error. The documentation is as follows:

Where you simply allow the shell running in your terminal to locate Flake8. In some cases, though, you may have installed Flake8 for multiple versions of Python (e.g., Python 2.7 and Python 3.5) and you need to call a specific version. In that case, you will have much better results using:

python2.7 -m flake8

When running it, I get the following error:

No module named flake8.__main__; 'flake8' is a package and cannot be directly executed

However, invoking it with just the command flake8 works just fine.

Community
  • 1
  • 1
John Snow
  • 1,898
  • 2
  • 27
  • 48
  • what version of flake8 are you using? I can't reproduce with 3.7.8 – anthony sottile Oct 05 '19 at 00:28
  • Make sure you do use Python 2.7 and not any lower version. See the first line of `flake8` script (`cat \`which flake8\` | head`) to find out what Python interpreter is used to run the script. Alternatively you could try running `python2.7 -m flake8.__main__`; see https://stackoverflow.com/a/6630931/95735 – Piotr Dobrogost Oct 18 '19 at 11:53

0 Answers0