4
$\begingroup$

I cannot get the ExternalEvaluate work for my Python. It says "missing dependencies" for the registration status. I have attached screenshots from Mathematica and Terminal. From the terminal screenshot you can see that I already have "pyzmq" installed. Does anyone have a solution to this?

terminal Mathematica

$\endgroup$
10
  • 1
    $\begingroup$ Use StartExternalSession and specify which exact Python executable you want to use. You have several installations and the one ExternalEvaluate would start does not have the dependencies installed. $\endgroup$
    – Szabolcs
    Sep 11 '19 at 7:17
  • $\begingroup$ Thanks for the reply. But the problem for me is that all the Python executables are missing dependencies? Why is that, how to fix it? $\endgroup$
    – baker
    Sep 12 '19 at 14:18
  • $\begingroup$ You must specify the path to the exact executable for which you installed the dependency. I don't see that one in the list. $\endgroup$
    – Szabolcs
    Sep 12 '19 at 15:59
  • 2
    $\begingroup$ Try this: Activate the anaconda environment you want to use. Make sure the dependencies are installed in this environment. Run which python to get the correct path to the python executable. Use this path with StartExternalSession. See the docs (under Details) for how. $\endgroup$
    – Szabolcs
    Sep 12 '19 at 20:00
  • 1
    $\begingroup$ It worked now! Thanks a lot. $\endgroup$
    – baker
    Sep 13 '19 at 21:48
1
$\begingroup$

The question has not yet receive a formal answer so I put one here from the comments of Szabolcs and baker.

First install pyzmq by opening a terminal window and entering

pip install pyzmq

(the process takes a few minutes). That should be it! In Mathematica, type

FindExternalEvaluators["Python"]

which should show all the Python installations available. Note that the column "Registered" should now indicate "Automatic" for those versions of Python compatible with both Mathematica and pyzmq.

From here, you can run Python code in Mathematica. /if there is a problem, you can specifically specify which version you wan to select with for example:

session = StartExternalSession[{"Python", "Version" -> "2.7.16"}]

Make sure that the version selected is registered.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.