Skip to main content

run python with package numpy in mathematica



For example, if I have a python script called simple.py contains as simple as


a=1
print(a)

then


RunProcess[{"python", "E:\\w\\simple.py"}]

is ok and gives


<|"ExitCode" -> 0, "StandardOutput" -> "1


", "StandardError" -> ""|>

However, if I edit simple.py as


import numpy as np
a=np.array([1,2])
print(a)

then


RunProcess[{"python", "E:\\w\\simple.py"}]


gives


<|"ExitCode" -> 1, "StandardOutput" -> "", 
"StandardError" -> "Traceback (most recent call last):

File \"E:\\w\\WORK\\python\\learning\\simple.py\", line 1, in \


import numpy as np

File \"D:\\IntelPython35\\lib\\site-packages\\numpy\\__init__.py\"\

, line 158, in

from . import add_newdocs

File \"D:\\IntelPython35\\lib\\site-packages\\numpy\\add_newdocs.\
py\", line 13, in

from numpy.lib import add_newdoc

File \"D:\\IntelPython35\\lib\\site-packages\\numpy\\lib\\__init__\

.py\", line 8, in

from .type_check import *

File \"D:\\IntelPython35\\lib\\site-packages\\numpy\\lib\\type_\
check.py\", line 11, in

import numpy.core.numeric as _nx

File \"D:\\IntelPython35\\lib\\site-packages\\numpy\\core\\__init_\

_.py\", line 21, in

from . import umath

ImportError: DLL load failed: ÕÒ\.b2»\[Micro]½Ö¸\[Paragraph]¨\
\[Micro]Ä\.b3ÌÐò¡£

"|>

What is wrong? How to make numpy work with RunProcess?





update


I've tried on a linux computer. The same python script works. So it is a problem of why RunProcess doesn't import packages correctly on windows?




update


A work around.


I uninstalled intel python and install anaconda.


Now it is working. Maybe intel python misses something in the PATH




Comments