Virtual environments equivalent in Matlab

16 views (last 30 days)
Hi everyone,
Is there any equivalent of Python's virtual environment in Matlab?
Here is my usecase: we are continuasly developing a toolbox for our projects, once a project is finished I'd like to be able to archive it with information of the specific version of the toolbox that was used for that analysis, so that if we ever need to rerun such analysis it is possible with one command to reset the environment of all the packages to the appropriate version (preferebly in an isolated way so that only the instance of Matlab that is running that project is affected). Very much how we can switch environments for different projects when working with Python.
Thank you
  1 Comment
Rik
Rik on 7 Dec 2024
I'm not aware of this being possible in Matlab.
However, most versioning is taken care of with the main Matlab version. All other code files can be copied. That is my strategy, so I haven't needed this option (although I do agree it has merit).

Sign in to comment.

Accepted Answer

Anjaneyulu Bairi
Anjaneyulu Bairi on 7 Dec 2024
Edited: Anjaneyulu Bairi on 7 Dec 2024
Hi,
MATLAB does not have a direct equivalent to Python's virtual environments,but you can use "projects" feature in the MATLAB.
It can help manage paths, dependencies, and settings specific to a project. You can create a project for each of your analyses, Projects can help you organize your work and collaborate. Use projects to find files required to run your code, manage and share files and settings, and interact with source control.
You can add only the necessary directories to the path for that project. You can add automated run scripts when opening or closing the project to set up the environment.
To know more about it, visit the below documentation link:
  1 Comment
Paulo
Paulo on 9 Dec 2024
Thanks, this seems like the closest we can get to a virtual environment. I'll definitely check it

Sign in to comment.

More Answers (1)

Joe Sanford
Joe Sanford on 8 Aug 2025
Yes. It is possible to use virtual environments with Python and MATLAB.
  2 Comments
Walter Roberson
Walter Roberson on 8 Aug 2025
The question is not how to use Python virtual environments in MATLAB. The question is how to use the equivalent of Python virtual environments to control MATLAB itself. A way to manage configurations of toolbox product versions (and presumably add-on versions) so that it is possible to (relatively easily) replicate the environment used to run something.
Joe Sanford
Joe Sanford on 8 Aug 2025
Edited: Joe Sanford on 8 Aug 2025
Oh! I misunderstood.
I would leverage MATLAB Projects in that case then. It's not exactly the same but would be helpful.
But, to really control the environment, you should consider running MATLAB in a Docker Container. This is also supported, link here.

Sign in to comment.

Categories

Find more on Performance and Memory in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!