jorgenschaefer/elpy

elpy-config error: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.

Opened this issue · 1 comments

Summary

Elpy-config isn't working for me on Emacs 29.1 (emacs-mac-app)..

It was throwing an error because, when the python script defined in elpy-config--get-config was evaluated, it threw the following warning:

"DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead ..."

** I was able to work around the problem by editing the elpy-config--get-config source to add the following line: **

warnings.filterwarnings('ignore', category=DeprecationWarning)

Steps to reproduce

Run elpy-config.

My configuration

OS

Mac OS Sonoma 14.2.1 (23C71), Python 3.11

emacs: emacs-mac-app (GNU Emacs 29.1 (build 1, aarch64-apple-darwin23.2.0, Carbon Version 170 AppKit 2487.3) of 2024-01-07)

Result of (elpy-config)

Elpy Configuration

Emacs.............: 29.1
Elpy..............: Not found (Python), 1.35.0 (Emacs Lisp)
Virtualenv........: None
Interactive Python: python3 3.11.7 (/opt/local/bin/python3)
RPC virtualenv....: rpc-venv (/Users/neal/.emacs.d/elpy/rpc-venv)
 Python...........: python nil (/opt/local/bin/python)
 Jedi.............: Not found
 Rope.............: Not found
 Autopep8.........: Not found
 Yapf.............: Not found
 Black............: Not found
Syntax checker....: flake8 (/opt/local/bin/flake8)

Warnings

You have not activated a virtual env. It is not mandatory but often a
good idea to work inside a virtual env. You can use `M-x
pyvenv-activate` or `M-x pyvenv-workon` to activate one.

The directory ~/.local/bin/ is not in your PATH. As there isElpy Configuration

Emacs.............: 29.1
Elpy..............: Not found (Python), 1.35.0 (Emacs Lisp)
Virtualenv........: None
Interactive Python: python3 3.11.7 (/opt/local/bin/python3)
RPC virtualenv....: rpc-venv (/Users/neal/.emacs.d/elpy/rpc-venv)
 Python...........: python nil (/opt/local/bin/python)
 Jedi.............: Not found
 Rope.............: Not found
 Autopep8.........: Not found
 Yapf.............: Not found
 Black............: Not found
Syntax checker....: flake8 (/opt/local/bin/flake8)

Warnings

You have not activated a virtual env. It is not mandatory but often a
good idea to work inside a virtual env. You can use `M-x
pyvenv-activate` or `M-x pyvenv-workon` to activate one.

 no active
virtualenv, installing Python packages locally will place executables
in that directory, so Emacs won't find them. If you are missing some
commands, do add this directory to your PATH -- and then do
`elpy-rpc-restart'.

The Python interpreter could not find the elpy module. Please report
to: https://github.com/jorgenschaefer/elpy/issues/new.

There was an unexpected problem starting the RPC process. Please check
the following output to see if this makes sense to you. To me, it
doesn't.

<string>:28: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
{"can_connect_to_pypi": true, "rpc_python_version": "3.11.7", "elpy_version": "1.35.0", "jedi_version": "0.19.1", "jedi_latest": null, "rope_version": "1.11.0"The directory ~/.local/bin/ is not in your PATH. As there is no active
virtualenv, installing Python packages locally will place executables
in that directory, so Emacs won't find them. If you are missing some
commands, do add this directory to your PATH -- and then do
`elpy-rpc-restart'.

The Python interpreter could not find the elpy module. Please report
to: https://github.com/jorgenschaefer/elpy/issues/new.

There was an unexpected problem starting the RPC process. Please check
the following output to see if this makes sense to you. To me, it
doesn't.

<string>:28: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
, "rope_latest": null, "autopep8_version": "2.0.4", "autopep8_latest": null, "yapf_version": "0.40.2", "yapf_latest": null, "black_version": "23.12.1", "black_latest": null}

Elpy could not connect to Pypi (or at least not quickly enough) and
check if the python packages were up-to-date. You can still try to
update all of them:

[Update python packages]

Pip doesn't seem to be installed in the dedicated virtualenv created
by Elpy (/Users/neal/.emacs.d/elpy/rpc-venv). This may prevent some
features from working properly (completion, documentation,
reformatting, ...). You can try reinstalling the virtualenv. If the
problem persists, please report on Elpy's github page.

[Reinstall RPC virtualenv]

The Jedi package is not currently installed. This package is ne{"can_connect_to_pypi": true, "rpc_python_version": "3.11.7", "elpy_version": "1.35.0", "jedi_version": "0.19.1", "jedi_latest": null, "rope_version": "1.11.0", "rope_latest": null, "autopep8_version": "2.0.4", "autopep8_latest": null, "yapf_version": "0.40.2", "yapf_latest": null, "black_version": "23.12.1", "black_latest": null}

Elpy could not connect to Pypi (or at least not quickly enough) and
check if the python packages were up-to-date. You can still try to
update all of them:

[Update python packages]

Pip doesn't seem to be installed in the dedicated virtualenv created
by Elpy (/Users/neal/.emacs.d/elpy/rpc-venv). This may prevent some
features from working properly (completion, documentation,
reformatting, ...). You can try reinstalling the virtualenv. If the
problem persists, please report on Elpy's github page.

[Reinstall RPC virtualenv]

eded
for code completion, code navigation and access to documentation.

[Install jedi]

No autoformatting package is currently installed. At least one is
needed (Autopep8, Yapf or Black) to perform autoformatting (`C-c C-r
f` in a python buffer).

[Install autopep8]
[Install yapf]
[Install black]

Options

`Raised' text indicates buttons; type RET or click mouse-1 on a button
to invoke its action.  Invoke [+] to expand a group, and [-] to
collapse an expanded group.  Invoke the [Group], [Face], and [Option]
buttons below to edit that item in another window.

[+]-- Group Elpy
[+]-- Group Python
[+]-- Group Virtual Environments (Pyvenv)
[ ]-- Group Completion (Company)
[+]-- Group Call Signatures (ElDoc)
[+]-- Group Inline Errors (Flymake)
[+]-- Group Code folThe Jedi package is not currently installed. This package is needed
for code completion, code navigation and access to documentation.

[Install jedi]

No autoformatting package is currently installed. At least one is
needed (Autopep8, Yapf or Black) to perform autoformatting (`C-c C-r
f` in a python buffer).

[Install autopep8]
[Install yapf]
[Install black]

Options

`Raised' text indicates buttons; type RET or click mouse-1 on a button
to invoke its action.  Invoke [+] to expand a group, and [-] to
collapse an expanded group.  Invoke the [Group], [Face], and [Option]
buttons below to edit that item in another window.

[+]-- Group Elpy
[+]-- Group Python
[+]-- Group Virtual Environments (Pyvenv)
[ ]-- Group Completion (Company)
[+]-- Group Call Signatures (ElDoc)
[+]-- Group Inline Errors (Flymake)
ding (hideshow)
[ ]-- Group Snippets (YASnippet)
[+]-- Group Directory Grep (rgrep)
[+]-- Group Search as You Type (ido)
[+]-- Group Django extension
[+]-- Group Autodoc extension
[+]-- Group Code folding (hideshow)
[ ]-- Group Snippets (YASnippet)
[+]-- Group Directory Grep (rgrep)
[+]-- Group Search as You Type (ido)
[+]-- Group Django extension
[+]-- Group Autodoc extension

Elpy configuration in my init.el

none

For others who encounter this, the line to patch is (currently) this one:

elpy/elpy.el

Line 640 in 777e990

warnings.filterwarnings('ignore', category=DeprecationWarning)