VRComp
VRComp

Reputation: 131

Deprecation Warnings: Distutils and netcdf_file

I get two deprecation warnings whenever I try running any python code. They are:

DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead. MIN_CHEMFILES_VERSION = LooseVersion("0.9")

DeprecationWarning: Please use netcdf_file from the scipy.io namespace, the scipy.io.netcdf namespace is deprecated.

I am not sure how to use packaging.version instead of distuils and netcdf file. I am running python 3.8. I tried updating my virtualenv as suggested here: DeprecationWarning in Python 3.6 and 3.7 (with Pillow, distutils, imp) This doesn't work for me. Any help will be appreciated.

I could not find results for the second deprecation warning.

Upvotes: 4

Views: 31666

Answers (2)

N1ngu
N1ngu

Reputation: 3824

The

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

message is caused by the distutils module being overridden since setuptools 60.0.0. You would notice because the distutils.__file__ variable evals to .../site-packages/setuptools/_distutils/__init__.py, regardless of your python interpreter. Using any python 3.8 or 3.9 will not fix the warning unless your installation features setuptools<60. And even then, the warning can still be triggered by setting SETUPTOOLS_USE_DISTUTILS=local in the environment.

See the breaking changes section in https://github.com/pypa/setuptools/blob/main/CHANGES.rst#v6000

Workarounds to suppress this warnings can be either to downgrade to setuptools<60 or to start your python interpreter with the SETUPTOOLS_USE_DISTUTILS=stdlib environment variable. But I discourage any of these approaches, be ready for worse side effects if you go this way.

Simply embrace the warning and try to contribute actual patches fixing this for any upstream library you were using before python 3.12 is released.

Upvotes: 12

burnettk
burnettk

Reputation: 14047

python 3.10 deprecated distutils. this is discussed in detail at https://peps.python.org/pep-0632/. it still works, but you're supposed to stop using it. probably a library you are depending on uses it, so there may or may not be much you can do for the moment if you have to use python 3.10 and you have already upgraded the relevant libraries. it's probably a similar story with scipy.

Upvotes: 7

Related Questions