Fail to install Matlab R2021b in Python 3.8/3.9 - setuptools error 'PEP 440'

Hello there,
I have been using MATLAB-Python connection for a while now with older Python versions and Matlab releases. However, recently in my environment with Python 3.9 I found an error to install MATLAB R2021b (only MATLAB version compatible with Python 3.9).
The error occurs when I run the setup.py file in extern/engines/python/dist see the error message below:
UserWarning: The version specified ('R2021b') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
warnings.warn(
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: no commands supplied
I believe it relates with the version numering of MATLAB being not valid for PEP 440. I checked by setuptools version and it is 60.2.0.
PS: I also tried to install R2021b in a newly created environment with Python 3.8 and setup tools 60.5.0 but got the same error.
Is there any solution to this error, or a way to avoid this version numbering check?
Thank you.

 Accepted Answer

The error goes away if the keyword ``install`` is used
python setup.py install

6 Comments

I have the same issue with python 3.8 and Matlab 2021b even install is used
python3.8 setup.py install
/home/runhuang/venv/py38/lib/python3.8/site-packages/setuptools/dist.py:561: UserWarning: The version specified ('R2021b') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
warnings.warn(
/home/runhuang/venv/py38/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
/home/runhuang/venv/py38/lib/python3.8/site-packages/setuptools/command/easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
/home/runhuang/venv/py38/lib/python3.8/site-packages/setuptools/_normalization.py:93: SetuptoolsDeprecationWarning: Invalid version: 'R2021b'.
I also have the same problem. MATLAB R2021b, Python 3.7 or 3.9 and setuptools==60.2.0 . I run as admin
In all cases i get the error:
File "C:\Users\...\envs\axcel_py\lib\site-packages\setuptools\_vendor\packaging\version.py", line 198, in __init__
raise InvalidVersion(f"Invalid version: '{version}'")
setuptools.extern.packaging.version.InvalidVersion: Invalid version: 'R2021b'
Any ideas how to fix this? I am on Windows 10 Enterprise
I faced same issue and still not resolved.
How did other fixed it ?
Please share.
The set of errors are as below .....
python setup.py install
C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\dist.py:315: SetuptoolsDeprecationWarning: Invalid version: 'R2021b'.
!!
********************************************************************************
The version specified is not a valid version according to PEP 440.
This may not work as expected with newer versions of
setuptools, pip, and PyPI.
This deprecation is overdue, please update your project and remove deprecated
calls to avoid build errors in the future.
See https://peps.python.org/pep-0440/ for details.
********************************************************************************
!!
self._validate_version(self.metadata.version)
C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\_distutils\cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************
Please avoid running ``setup.py`` directly.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
********************************************************************************
!!
self.initialize_options()
C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\_distutils\cmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running ``setup.py`` and ``easy_install``.
Instead, use pypa/build, pypa/installer or other
standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
self.initialize_options()
C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\command\egg_info.py:130: SetuptoolsDeprecationWarning: Invalid version: 'R2021b'.
!!
********************************************************************************
Version 'R2021b' is not valid according to PEP 440.
Please make sure to specify a valid version for your package.
Also note that future releases of setuptools may halt the build process
if an invalid version is given.
This deprecation is overdue, please update your project and remove deprecated
calls to avoid build errors in the future.
See https://peps.python.org/pep-0440/ for details.
********************************************************************************
!!
return _normalization.best_effort_version(tagged)
Traceback (most recent call last):
File "C:\Program Files\MATLAB\R2021b\extern\engines\python\setup.py", line 80, in <module>
setup(
File "C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\_distutils\core.py", line 185, in setup
return run_commands(dist)
File "C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands
dist.run_commands()
File "C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\_distutils\dist.py", line 969, in run_commands
self.run_command(cmd)
File "C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\dist.py", line 989, in run_command
super().run_command(command)
File "C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
cmd_obj.run()
File "C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\command\install.py", line 84, in run
self.do_egg_install()
File "C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\command\install.py", line 132, in do_egg_install
self.run_command('bdist_egg')
File "C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command
self.distribution.run_command(command)
File "C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\dist.py", line 989, in run_command
super().run_command(command)
File "C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\_distutils\dist.py", line 987, in run_command
cmd_obj.ensure_finalized()
File "C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\_distutils\cmd.py", line 111, in ensure_finalized
self.finalize_options()
File "C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\command\bdist_egg.py", line 95, in finalize_options
ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info")
File "C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\_distutils\cmd.py", line 305, in get_finalized_command
cmd_obj.ensure_finalized()
File "C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\_distutils\cmd.py", line 111, in ensure_finalized
self.finalize_options()
File "C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\command\egg_info.py", line 224, in finalize_options
parsed_version = packaging.version.Version(self.egg_version)
File "C:\Users\dines\.conda\envs\tf\lib\site-packages\setuptools\_vendor\packaging\version.py", line 198, in __init__
raise InvalidVersion(f"Invalid version: '{version}'")
setuptools.extern.packaging.version.InvalidVersion: Invalid version: 'R2021b'
I am using virtual environment using conda with python python version 3.19.18 . As per the document it should support the version.
Edit matlabroot/extern/engines/python/setup.py. At the end of the file in the setup() call, change the version= argument to the numeric version found in matlabroot/VersionInfo.xml.
This has been fixed in later versions of MATLAB (setup.py now has a PEP 440-compatible version number)

Sign in to comment.

More Answers (0)

Products

Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!