Python API cannot be built with setup.py in R2021a
I’m trying to get the matlab engine python API to work as I have a long piece of python code which inherits a single call to a MATLAB function.
For sanitary reasons, I want to couple to API to one of my virtual anaconda environments. As I’m using the R2021a release I’ve started by creating a new conda environment with python 3.8 as per the compatibility requirements Versions of Python Compatible with MATLAB Products by Release – MATLAB & Simulink (mathworks.com), and installing no further libraries. Afterwards a python –version reveals this installed Python 3.8.16.
In MATLAB I’ve confirmed the license is activated by running
license(‘inuse’)
which returns "matlab" as I went with a complete blank installation after multiple failed attempts.
When trying to actually built the engine, I’m aware I have to specify the associated python directory with the virtual environment as explained in Install MATLAB Engine API for Python in Nondefault Locations – MATLAB & Simulink – MathWorks Benelux as the default Python environment runs in an incompatible version, so I execute
"python setup.py install –prefix="C:<my_anaconda_path>envsmatlab-api-env"
which returns the following lengthy error message
=============================================================================================================
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolsdist.py:520: SetuptoolsDeprecationWarning: Invalid version: ‘R2021a’.
!!
********************************************************************************
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.
By 2023-Sep-26, you need to update your project and remove deprecated calls
or your builds will no longer be supported.
See https://peps.python.org/pep-0440/ for details.
********************************************************************************
!!
self._validate_version(self.metadata.version)
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ directly.
Instead, use pypa/build, pypa/installer, pypa/build or
other standards-based tools.
See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
********************************************************************************
!!
self.initialize_options()
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ and “easy_install“.
Instead, use pypa/build, pypa/installer, pypa/build or
other standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
self.initialize_options()
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandegg_info.py:131: SetuptoolsDeprecationWarning: Invalid version: ‘R2021a’.
!!
********************************************************************************
Version ‘R2021a’ 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.
By 2023-Sep-26, you need to update your project and remove deprecated calls
or your builds will no longer be supported.
See https://peps.python.org/pep-0440/ for details.
********************************************************************************
!!
return _normalization.best_effort_version(tagged)
Traceback (most recent call last):
File "setup.py", line 80, in <module>
setup(
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscore.py", line 185, in setup
return run_commands(dist)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscore.py", line 201, in run_commands
dist.run_commands()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilsdist.py", line 969, in run_commands
self.run_command(cmd)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolsdist.py", line 1244, in run_command
super().run_command(command)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilsdist.py", line 988, in run_command
cmd_obj.run()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandinstall.py", line 80, in run
self.do_egg_install()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandinstall.py", line 129, in do_egg_install
self.run_command(‘bdist_egg’)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 318, in run_command
self.distribution.run_command(command)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolsdist.py", line 1244, in run_command
super().run_command(command)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilsdist.py", line 987, in run_command
cmd_obj.ensure_finalized()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 111, in ensure_finalized
self.finalize_options()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandbdist_egg.py", line 92, in finalize_options
ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info")
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 305, in get_finalized_command
cmd_obj.ensure_finalized()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 111, in ensure_finalized
self.finalize_options()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandegg_info.py", line 219, in finalize_options
parsed_version = packaging.version.Version(self.egg_version)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_vendorpackagingversion.py", line 197, in __init__
raise InvalidVersion(f"Invalid version: ‘{version}’")
setuptools.extern.packaging.version.InvalidVersion: Invalid version: ‘R2021a’
=============================================================================================================
So it seems that the official way of creating the MATLAB-python API through the setup.py script is depracated in the default setuptools (ver 67.2.2.) that comes with a fresh python 3.8 installation. The suggested alternative based to use pip install instead (based on Why you shouldn’t invoke setup.py directly (ganssle.io)), is only supported for R2022b and upwards according to Install MATLAB Engine API for Python – MATLAB & Simulink – MathWorks Benelux (and trying to do so despite the lack official support still generates a similar error surrounding SetuptoolsDeprecationWarning: Invalid version: ‘R2021a’).
Any help would be appreciated.I’m trying to get the matlab engine python API to work as I have a long piece of python code which inherits a single call to a MATLAB function.
For sanitary reasons, I want to couple to API to one of my virtual anaconda environments. As I’m using the R2021a release I’ve started by creating a new conda environment with python 3.8 as per the compatibility requirements Versions of Python Compatible with MATLAB Products by Release – MATLAB & Simulink (mathworks.com), and installing no further libraries. Afterwards a python –version reveals this installed Python 3.8.16.
In MATLAB I’ve confirmed the license is activated by running
license(‘inuse’)
which returns "matlab" as I went with a complete blank installation after multiple failed attempts.
When trying to actually built the engine, I’m aware I have to specify the associated python directory with the virtual environment as explained in Install MATLAB Engine API for Python in Nondefault Locations – MATLAB & Simulink – MathWorks Benelux as the default Python environment runs in an incompatible version, so I execute
"python setup.py install –prefix="C:<my_anaconda_path>envsmatlab-api-env"
which returns the following lengthy error message
=============================================================================================================
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolsdist.py:520: SetuptoolsDeprecationWarning: Invalid version: ‘R2021a’.
!!
********************************************************************************
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.
By 2023-Sep-26, you need to update your project and remove deprecated calls
or your builds will no longer be supported.
See https://peps.python.org/pep-0440/ for details.
********************************************************************************
!!
self._validate_version(self.metadata.version)
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ directly.
Instead, use pypa/build, pypa/installer, pypa/build or
other standards-based tools.
See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
********************************************************************************
!!
self.initialize_options()
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ and “easy_install“.
Instead, use pypa/build, pypa/installer, pypa/build or
other standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
self.initialize_options()
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandegg_info.py:131: SetuptoolsDeprecationWarning: Invalid version: ‘R2021a’.
!!
********************************************************************************
Version ‘R2021a’ 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.
By 2023-Sep-26, you need to update your project and remove deprecated calls
or your builds will no longer be supported.
See https://peps.python.org/pep-0440/ for details.
********************************************************************************
!!
return _normalization.best_effort_version(tagged)
Traceback (most recent call last):
File "setup.py", line 80, in <module>
setup(
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscore.py", line 185, in setup
return run_commands(dist)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscore.py", line 201, in run_commands
dist.run_commands()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilsdist.py", line 969, in run_commands
self.run_command(cmd)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolsdist.py", line 1244, in run_command
super().run_command(command)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilsdist.py", line 988, in run_command
cmd_obj.run()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandinstall.py", line 80, in run
self.do_egg_install()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandinstall.py", line 129, in do_egg_install
self.run_command(‘bdist_egg’)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 318, in run_command
self.distribution.run_command(command)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolsdist.py", line 1244, in run_command
super().run_command(command)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilsdist.py", line 987, in run_command
cmd_obj.ensure_finalized()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 111, in ensure_finalized
self.finalize_options()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandbdist_egg.py", line 92, in finalize_options
ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info")
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 305, in get_finalized_command
cmd_obj.ensure_finalized()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 111, in ensure_finalized
self.finalize_options()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandegg_info.py", line 219, in finalize_options
parsed_version = packaging.version.Version(self.egg_version)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_vendorpackagingversion.py", line 197, in __init__
raise InvalidVersion(f"Invalid version: ‘{version}’")
setuptools.extern.packaging.version.InvalidVersion: Invalid version: ‘R2021a’
=============================================================================================================
So it seems that the official way of creating the MATLAB-python API through the setup.py script is depracated in the default setuptools (ver 67.2.2.) that comes with a fresh python 3.8 installation. The suggested alternative based to use pip install instead (based on Why you shouldn’t invoke setup.py directly (ganssle.io)), is only supported for R2022b and upwards according to Install MATLAB Engine API for Python – MATLAB & Simulink – MathWorks Benelux (and trying to do so despite the lack official support still generates a similar error surrounding SetuptoolsDeprecationWarning: Invalid version: ‘R2021a’).
Any help would be appreciated. I’m trying to get the matlab engine python API to work as I have a long piece of python code which inherits a single call to a MATLAB function.
For sanitary reasons, I want to couple to API to one of my virtual anaconda environments. As I’m using the R2021a release I’ve started by creating a new conda environment with python 3.8 as per the compatibility requirements Versions of Python Compatible with MATLAB Products by Release – MATLAB & Simulink (mathworks.com), and installing no further libraries. Afterwards a python –version reveals this installed Python 3.8.16.
In MATLAB I’ve confirmed the license is activated by running
license(‘inuse’)
which returns "matlab" as I went with a complete blank installation after multiple failed attempts.
When trying to actually built the engine, I’m aware I have to specify the associated python directory with the virtual environment as explained in Install MATLAB Engine API for Python in Nondefault Locations – MATLAB & Simulink – MathWorks Benelux as the default Python environment runs in an incompatible version, so I execute
"python setup.py install –prefix="C:<my_anaconda_path>envsmatlab-api-env"
which returns the following lengthy error message
=============================================================================================================
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolsdist.py:520: SetuptoolsDeprecationWarning: Invalid version: ‘R2021a’.
!!
********************************************************************************
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.
By 2023-Sep-26, you need to update your project and remove deprecated calls
or your builds will no longer be supported.
See https://peps.python.org/pep-0440/ for details.
********************************************************************************
!!
self._validate_version(self.metadata.version)
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ directly.
Instead, use pypa/build, pypa/installer, pypa/build or
other standards-based tools.
See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
********************************************************************************
!!
self.initialize_options()
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running “setup.py“ and “easy_install“.
Instead, use pypa/build, pypa/installer, pypa/build or
other standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
self.initialize_options()
C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandegg_info.py:131: SetuptoolsDeprecationWarning: Invalid version: ‘R2021a’.
!!
********************************************************************************
Version ‘R2021a’ 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.
By 2023-Sep-26, you need to update your project and remove deprecated calls
or your builds will no longer be supported.
See https://peps.python.org/pep-0440/ for details.
********************************************************************************
!!
return _normalization.best_effort_version(tagged)
Traceback (most recent call last):
File "setup.py", line 80, in <module>
setup(
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscore.py", line 185, in setup
return run_commands(dist)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscore.py", line 201, in run_commands
dist.run_commands()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilsdist.py", line 969, in run_commands
self.run_command(cmd)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolsdist.py", line 1244, in run_command
super().run_command(command)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilsdist.py", line 988, in run_command
cmd_obj.run()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandinstall.py", line 80, in run
self.do_egg_install()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandinstall.py", line 129, in do_egg_install
self.run_command(‘bdist_egg’)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 318, in run_command
self.distribution.run_command(command)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolsdist.py", line 1244, in run_command
super().run_command(command)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilsdist.py", line 987, in run_command
cmd_obj.ensure_finalized()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 111, in ensure_finalized
self.finalize_options()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandbdist_egg.py", line 92, in finalize_options
ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info")
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 305, in get_finalized_command
cmd_obj.ensure_finalized()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_distutilscmd.py", line 111, in ensure_finalized
self.finalize_options()
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptoolscommandegg_info.py", line 219, in finalize_options
parsed_version = packaging.version.Version(self.egg_version)
File "C:Userss162286AppDataLocalanaconda3envsmatlab-api-envlibsite-packagessetuptools_vendorpackagingversion.py", line 197, in __init__
raise InvalidVersion(f"Invalid version: ‘{version}’")
setuptools.extern.packaging.version.InvalidVersion: Invalid version: ‘R2021a’
=============================================================================================================
So it seems that the official way of creating the MATLAB-python API through the setup.py script is depracated in the default setuptools (ver 67.2.2.) that comes with a fresh python 3.8 installation. The suggested alternative based to use pip install instead (based on Why you shouldn’t invoke setup.py directly (ganssle.io)), is only supported for R2022b and upwards according to Install MATLAB Engine API for Python – MATLAB & Simulink – MathWorks Benelux (and trying to do so despite the lack official support still generates a similar error surrounding SetuptoolsDeprecationWarning: Invalid version: ‘R2021a’).
Any help would be appreciated. python, matlab-engine, setup.py, setuptools MATLAB Answers — New Questions