12
$\begingroup$

Long time ago, I have two versions of python installed in my pc, and I registered them all in mathematica. Later I uninstalled one of them, but FindExternalEvaluators["Python"] still gived me two results, and then when I wanted to run StartExternalSession["Python"],it tried to launch the uninstalled one first and gived me a lot of warning. The uninstalled Python is neither in the path of my system nor in the path of mathematica, and UnregisterExternalEvaluator doesn't work either. So how can I do if I want to get one result when I run FindExternalEvaluators["Python"]? My system is windows 10, version of mathematica is 11.2.

$\endgroup$
2
  • 3
    $\begingroup$ You can start with a clean slate by evaluating ExternalEvaluate; ExternalEvaluate`Private`resetCache[] which will clear the cached external evaluator instances. $\endgroup$
    – ilian
    Mar 12, 2018 at 1:36
  • $\begingroup$ It works. Thank you! $\endgroup$
    – Jie Zhu
    Mar 13, 2018 at 3:33

2 Answers 2

15
$\begingroup$

Update: As of version 12, one should use

FindExternalEvaluators["Python", "ResetCache" -> True]

To turn my comment into an answer, ExternalEvaluate keeps a cache of evaluators it has found or used previously, and sometimes it can make invalid data persist.

In such cases, it is often useful to start with a clean slate, using the following command

ExternalEvaluate; (* trigger autoloading *)

ExternalEvaluate`Private`resetCache[]

which will clear the cached data.

$\endgroup$
4
  • $\begingroup$ This appears to no longer work in version 12.2. $\endgroup$
    – david
    Dec 24, 2020 at 20:11
  • $\begingroup$ Thanks @david, I made an edit. $\endgroup$
    – ilian
    Jan 19, 2021 at 21:37
  • $\begingroup$ Yes @ilian, that did the trick. Thanks. $\endgroup$
    – david
    Jan 19, 2021 at 22:45
  • $\begingroup$ @ilian I have the exact same problem with Mathematica 12.3.1 but it doesn't work. Any thoughts? Launching the command give me "The code execution cannot proceed because python37.dll was not found" That's why I want to get rid of it! $\endgroup$
    – Lou
    Nov 24, 2021 at 16:03
1
$\begingroup$

Just as additional information. I found the above not to work at all. I received a (not wolfram message) "The code execution cannot proceed because python37.dll was not found". I don't really understand how the external evaluator registration works it's dependency's etc. Would be nice to have WRI document this (like the "ResetCache" option) Anyway I had the Registered status for Python 3.7 as MissingDependencies. I also had an old Anaconda installation with a Python version. But both versions where de-installed through windows add/remove programs

Unregister anaconda version The path shown in the Target was pointing to a path that did not exist. Recreating the path and copying a python.exe in there resolved the issue. This version was successfully unregistered.

Unregister the python 3.7 version What helped at the end was to re-install the same version of python in that directory. Re-Install PyZMQ. Then I could unregister the Python registration. Then I de-installed the Python version again.

After this I installed the latest Python version (3.10), upgraded Pip and installed pyZMQ after that the FindExternalEvaluators["Python"] found the installation and the status "Registered" was False. I registered the version manually and now everything works fine.

$\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.