. Advertisement .
..3..
. Advertisement .
..4..
“AttributeError: module ‘setuptools._distutils’ has no attribute ‘version'” is a common exception that occurs when there is an error in importing or accessing a Python module. This article details one step-by-step process of how to fix an error that can occur when trying to use package setuptools. This article is also helpful for those who may not know why the error occurs or what the best course of action is.
What is “AttributeError: module ‘setuptools._distutils’ has no attribute ‘version’”?
When you execute your Python project, you may get the following error.
AttributeError: module 'setuptools._distutils' has no attribute 'version'
Cause of the error
The main cause of the above error is usually because the version of Setuptools you installed in your machine is too high. The approach to deal with it is that you can downgrade the version you are using.
How to fix it?
Here are some approaches for you to fix the above error. Please consult and choose the plan that is suitable for you.
Approach 1: Use the lower setuptools version
Simply downgrade setuptools to version 59.5.0. Now, you have solved your problem. Firstly, use the following command to install setuptools:
pip uninstall setuptools
hen, to install setuptools 59.5.0, execute this command. For Python 3:
python3 -m pip install setuptools==59.5.0
For Python 2:
python2 -m pip install setuptools==59.5.0
Approach 2:
Beside that, you can try the following:
Using:
Successfully installed setuptools-60.1.0
Instead of:
setuptools-60.2.0
Approach 3: Utilize nightly-release of PyTorch
If you’re utilizing PyTorch and getting this problem, you should consider using the PyTorch nightly release. Your problem should now be resolved.
Conclusion
We hope you enjoyed our article about the error. With this knowledge, we know that you can fix your error: “AttributeError: module ‘setuptools._distutils’ has no attribute ‘version’” quickly by following these steps! If you still have any other questions about fixing this syntax error, please leave a comment below. Thank you for reading!
Leave a comment