0
$\begingroup$

Ever since upgrading to Mathematica 12, I have been unable to import a local module in Python that I need for an ExternalEvaluate session.

Here is what I have that worked perfectly in Mathematica 11 but now it does not.

session = StartExternalSession["Python-NumPy"];
ExternalEvaluate[session, "os.chdir('directory_address')"];
ExternalEvaluate[session, "sys.path.insert(1, 'directory_address')"];
ExternalEvaluate[session, "import myModule"]

Where directory_address is the directory where the module myModule.py lives. (I have removed it for anonymity reasons)

Is there a change from Mathematica 11 to Mathematica 12 that I have missed? Those Python lines of code work fine when I run them within Python in my command line.

$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.