pyversion: "Path argument does not specify a valid executable."

Hi,
I have 32-bit version of MATLAB 2014b (8.4.0.150421 (R2014b)) and a 32 bit version of python (Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win32) on a windows 7 64-bit machine. I installed python using the standard installer on python.org. I have python in the system path (which MATLAB confirms when I use a "getenv('PATH')" command.) Every time I try to get pyversion to recognize python, I get "Error using pyversion: Path argument does not specify a valid executable." I have tired using just 2.7 as an argument as well as the full path to the executable 'C:\Python27\python.exe'. (And I've confirmed python really is there.) Is there something I'm missing, or haven't set up properly?
Thanks!

5 Comments

I tried 32-bit Python with 32-bit MATLAB on 64-bit Windows and it worked for me. Did you check that Python is working properly? You could try running a few commands from MATLAB with bang.
>> !C:\Python27_32\pythonw.exe -V
Python 2.7.9
>> !C:\Python27_32\pythonw.exe -c "import sys; print sys.executable, sys.prefix"
C:\Python27_32\pythonw.exe C:\Python27_32
>>
Another issue could be the location of python27.dll. If you installed Python for only the current user, it is located in the same folder as the executable.
Thank you very much for trying this on your computer. When I do
!C:\Python27\python.exe -V
I get the version. When I do
!C:\Python27\pythonw.exe -V
I get no output, but it does return w/o any error. The command you had passing code works just like you have with python.exe.
Thank you for your reply and help with this!
One other thing that's really strange. I can call MATLAB from python, and when I do pyversion gives the correct value.
>>> eng = matlab.engine.start_matlab();
>>> eng.pyversion();
'2.7'
What about pyversion with nargout=0?
>>> eng.pyversion(nargout=0)
Python environment settings are stored in matlab.settings file in the prefdir (MATLAB preferences directory) of user which is MATLAB is started by. They are in section:
<settings name="external">
<settings name="interfaces">
<settings name="python">
<key name="Version">
Under my Win 8.1 environment, for example, they look like this:
<string minArraySize="4" maxArraySize="4">
<value><![CDATA[3.4]]></value>
<value><![CDATA[C:\Anaconda3\python.exe]]></value>
<value><![CDATA[C:\Anaconda3]]></value>
<value><![CDATA[C:\Anaconda3\python34.dll]]></value>
</string>
Under Ubuntu environment it looks like this:
<string minArraySize="4" maxArraySize="4">
<value><![CDATA[3.4]]></value>
<value><![CDATA[/root/anaconda3/bin/python]]></value>
<value><![CDATA[/root/anaconda3]]></value>
<value><![CDATA[/root/anaconda3/lib/libpython3.4m.so]]></value>
</string>
When I've got an error Joe Sheridan have mentioned, I just inserted applicable paths into matlab.settings directly.
Also, at least under Ubuntu it is hard to predict, which matlab.settings file MATLAB will use - I've ran into cases when MATLAB was started under one user and was using matlab.settings of another user.

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Asked:

on 5 Feb 2015

Commented:

on 22 Oct 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!