2

I am writing a package to give to someone else so I am trying to make installation, dependencies, and use as simple as possible. The top-level calls for the package are in MATLAB but, at one point, I'd like to run a Python script from my MATLAB function. I don't know if the user will be on Unix or Windows. So far, I have used a Conda environment for my Python scripts because it uses specific versions of Scipy and Tensorflow.

Is there a platform-independent way to activate a Conda environment and call a Python script from MATLAB? Or even better, have a copy of Python (and it's dependencies) in a subdirectory of the MATLAB script so I could, for instance, give the entire package on a USB stick and not worry about different Python installations?

Thanks for any insight.

2

1 Answer 1

0

There is not a platform-independent method to make MATLAB use a conda environment. However, as I mentioned in this answer, you can explicitly tell MATLAB where to look for the Python interpreter and libraries of your environment, and can even de-bug without having to restart MATLAB every time you change the Python script you are trying to run.

You do not need to activate the conda environment before using it from MATLAB, so that part of your question is moot. MATLAB simply uses the interpreter, so as long as all of the necessary libraries are installed in the conda environment, your Python code will run from MATLAB.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.