jorgenschaefer / elpy

Emacs Python Development Environment
GNU General Public License v3.0
1.9k stars 262 forks source link

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

Open dhdaines opened 2 years ago

dhdaines commented 2 years ago

Same problem as #1938 and #1939, though it isn't due to Python 3.10 but rather the most recent versions of pip and setuptools in Python 3.8, I think. With pip 22.1.2 and setuptools 62.1.0, and I get this error from elpy-config (slightly reformatted):

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.8.10", "elpy_version": "1.35.0", "jedi_version": "0.18.1",
"jedi_latest": null, "rope_version": "1.1.1", "rope_latest": null, "autopep8_version": "1.6.0",
"autopep8_latest": null, "yapf_version": "0.32.0", "yapf_latest": null, "black_version": "22.3.0",
"black_latest": null}

I am using elpy 1.35.0 on Emacs 26.3 on Ubuntu 20.04.

The problem is "fixed" by downgrading setuptools to 59.8.0, which does not emit this deprecation warning, but I guess it is actually caused by some kind of version specifier in elpy that setuptools doesn't agree with.

windsurfer915 commented 2 years ago

i have this problem too - i am using latest (as of date of this post) python 3.9 (via brew with /usr/bin /usr/local/bin pointing to this python), latest elpy, all brew and emacs packages up to date, let elpy install dependencies into rpc-venv.

However after downgrading to setuptools to 59.8.0 and rebuilding the rpc-venv with M-x elpy-rpc-reinstall-virtualenv and saying "y" to install dependencies I still have the same error.

bradhowes commented 2 years ago

I believe this is due to the use of LooseVersion when checking for the latest version of the packages. I fixed this by changing elpy-config--get-config variable in elpy.el to have:

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

Add after the one for FutureWarning. You will need to reevaluate the variable to update its value. You should then get a good result from elpy-config

egk-ts commented 1 year ago

1946 works around this by suppressing the error.

https://stable.melpa.org/#/elpy currently points to 1.35.0 which doesn't have this fix, which is how I encountered this. https://melpa.org/#/elpy includes the fix, so a solution is to get elpy from the non-stable.

fdouglis commented 12 months ago

I'm confused. This has been flagged as deprecated for some time, and now doesn't exist at all, yet master still loads distutil (resulting in a stronger error than just the "deprecated" message cited here. Why is it still there?