-
-
Notifications
You must be signed in to change notification settings - Fork 68
fix ModuleNotFoundError: No module named 'distutils' in python version > 3.12
#107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…on >= 3.12 distutils is deprecated since python version 3.12, this is a temporary patch. details: https://docs.python.org/3/whatsnew/3.12.html#summary-release-highlights > PEP 632: Remove the distutils package. See the migration guide for advice replacing the APIs it provided. The third-party Setuptools package continues to provide distutils, if you still require it in Python 3.12 and beyond.
|
@purplewall1206 Hi and thank you for the merge request. Does this actually fix the exception? Because the documentation says that the "setuptools" package still provides the "distutils" module. And this aligns with my experience - what is needed is to install "setuptools" - and I have been able to make the exception go away by doing that (without any change to the imports). Does that not work for you? |
|
@jonnor Thanks for replying.
Yes, I use
Unfortunately, no. We cannot avoid modifying the
|
|
The "setuptools" package should install "distutils" module. |
|
The root cause seems to be that I am running the emlearn code on Windows 11. I have confirmed the version of setuptools, and the result is as follows: PS D:\workspace\> python3 -c 'import setuptools; print(setuptools.__version__)'
75.7.0 |
| # create a new compiler object | ||
| # force re-compilation even if object files exist (required) | ||
| cc = new_compiler(force=1) | ||
| cc = _distutils.new_compiler(force=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This must be "distutils", not _distutils?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either will work on windows 11, distutils looks better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_distutils will not work on other platforms, so that must be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, there is another usage of new_compiler that must also be updated.
And new_compiler is not in "distutils" module - but in "distutils.ccompiler", so that also needs to be fixed.
In general, please make sure to run the test suite when/before submitting a patch. It catches all these issues.
|
@purplewall1206 aha. My ability to test on Windows is a bit limited. Anyway, I think that - if you chance the code to first try from "setuputils import distutils", but catch ImportError and then try distutils - then the change can go in and we are sure it also will work as it used to. |
distutilsis deprecated since python version 3.12, this is a temporary patch to avoidModuleNotFoundError: No module named 'distutils'errorsdetails:
https://docs.python.org/3/whatsnew/3.12.html#summary-release-highlights