I'm struggling to get line length correctly setup under Elpy.
I found How to customize the line character length in elpy? and have in the past found flycheck cannot find module for pylint.
My configuration looks like (I've tried both autopep8
and yapf
)...
(add-hook 'python-mode-hook
(lambda ()
(setq flycheck-python-pylint-executable "~/.virtualenvs/default/bin/pylint")
(setq flycheck-pylintrc "~/.emacs.d/settings/.pylintrc")))
;; enable autopep8 formatting on save
(require 'py-autopep8)
(add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)
;; (require 'py-yapf)
;; (add-hook 'python-mode-hook 'py-yapf-enable-on-save)
I have as per the suggestions in autopep8 · PyPI created ~/.config/pycodestyle
which contains...
[pycodestyle]
max_line_length = 120
ignore = E501
...and yet on saving a file it doesn't apply the 120 character rule in so much as lines that are > 120 characters are not auto-formatted and still reports in *Messages*
...
line too long (124 > 79 characters) [E501] [2 times]
I've also set the following configuration option
(setq-default fill-column 120)
...which I'm unsure whether it will be interfering with things.
Any ideas or suggestions on how to configure autopep8 to automatically split lines at 120 characters would be very gratefully received as I feel like I've been going round in circles, despite seemingly trying the suggested solutions (I admit I may have misunderstood how to do this though or just cocked things up!).
EDIT 2020-12-29
In light of answer from Chin-Ben I checked elpy-config
I get...
Elpy Configuration
Emacs.............: 27.1
Elpy..............: 1.35.0
Virtualenv........: python3_9 (/home/neil/.virtualenvs/python3_9/)
Interactive Python: ipython 7.16.1 (/home/neil/.virtualenvs/python3_9/bin/ipython)
RPC virtualenv....: rpc-venv (/home/neil/.config/emacs/elpy/rpc-venv)
Python...........: python3 3.6.12 (/home/neil/.config/emacs/elpy/rpc-venv/bin/python3)
Jedi.............: 0.16.0 (0.18.0 available)
Rope.............: 0.16.0
Autopep8.........: 1.5 (1.5.4 available)
Yapf.............: 0.29.0 (0.30.0 available)
Black............: 19.10b0 (20.8b1 available)
Syntax checker....: flake8 (/home/neil/.virtualenvs/python3_9/bin/flake8)
Warnings
There is a newer version of Jedi available.
[Update jedi]
There is a newer version of the autopep8 package available.
[Update autopep8]
There is a newer version of the yapf package available.
[Update yapf]
There is a newer version of the black package available.
[Update black]
...and have duly updated jedi
/autopep8
/yapf
/black
all of which are from the RPC env, but in doing so I noticed that pip
was outdated as it reported...
You are using pip version 18.1, however version 20.3.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
There are many versions of pip
installed on my system in various places, one in ~/.local/bin/pip
along with many other commands (all dated from 2018, possibly from where I did a pip install --user
before I understood virtual environments correctly).
Removing ~/.local/bin/pip
didn't resolve this so its something else out of the many being picked up out of...
❱ locate pip | grep bin | grep 'pip$'
/home/user/.config/emacs/elpy/rpc-venv/bin/pip
/home/user/.local/bin/pip
/home/user/.virtualenvs/elpy-rpc-venv/bin/pip
/home/user/.virtualenvs/floow_jobs/bin/pip
/home/user/.virtualenvs/python3_9/bin/pip
/home/user/.virtualenvs/python3_9/default/bin/pip
/home/user/.virtualenvs/tcx2gpx-test/bin/pip
/home/user/.virtualenvs/test/bin/pip
/usr/bin/pip
Its not the system that is being picked up as that is up-to-date, the elpy-rpc-venv
one is up-to-date too, but the ~/.config/emacs/elpy/rpc-venv/bin/pip
reports an error which is informative...
❱ /usr/bin/pip --version
pip 20.3.3 from /usr/lib/python3.8/site-packages/pip (python 3.8)
❱ /home/user/.virtualenvs/elpy-rpc-venv/bin/pip --version
pip 20.3.3 from /home/user/.virtualenvs/elpy-rpc-venv/lib/python3.6/site-packages/pip (python 3.6)
❱ /home/user/.config/emacs/elpy/rpc-venv/bin/pip --version
zsh: /home/user/.config/emacs/elpy/rpc-venv/bin/pip: bad interpreter: /home/neil/.emacs.d/elpy/rpc-venv/bin/python3: no such file or directory
...and I've been having trouble with Jedi complaining about the EPC Server configuration...
Error (jedi):
================================
Failed to start Jedi EPC server.
================================
*** EPC Error ***
make client process failed
*** EPC Server Config ***
Server arguments: ("/home/user/.virtualenvs/python3_9/default/bin/jediepcserver")
Actual command: /home/user/.virtualenvs/python3_9/default/bin/jediepcserver
VIRTUAL_ENV envvar: "/home/user/.virtualenvs/python3_9/"
*** jedi-mode is disabled in #<buffer test.py> ***
Fix the problem and re-enable it.
*** You may need to run "M-x jedi:install-server". ***
This could solve the problem especially if you haven't run the command yet
since Jedi.el installation or update and if the server complains about
Python module imports.
...which the suggested course of action (M-x jedi:install-server
) did not resolve. What stands out though is that...
❱ /home/user/.config/emacs/elpy/rpc-venv/bin/pip --version
zsh: /home/user/.config/emacs/elpy/rpc-venv/bin/pip: bad interpreter: /home/user/.emacs.d/elpy/rpc-venv/bin/python3: no such file or directory
...indicates that something has gone awry when I moved from keeping my config under ~/.emacs.d
to ~/.config/emacs/
a while back.
Suffice to say it looks like my virtual environments/EPC server are not working as intended, but this has been really useful in helping to identify this as I was baffled as to why I couldn't fix things.
elpy
.