mlabwrap setup query
Asked Answered
A

1

12

I happened to stumble upon an answer posted by user brentlance regarding the linking of Matlab to Python, and was wondering if I could ask the community for some advice regarding the initial setup of the mlabwrap module.

I'm on Windows 7 32 bit, using Matlab R2012a and Python 2.7 (from the Python(x,y) scientific computing package). When I try to run:

python setup.py install

in the malbwrap directory, the console returns a very large error, as presented:

WINDOWS SPECIFIC ISSUE? Unable to remove c:\users\nathan\appdata\local\temp\tmpv
tzipc; please delete it manually
[Error 32] The process cannot access the file because it is being used by anothe
r process: 'c:\\users\\nathan\\appdata\\local\\temp\\tmpvtzipc'

running install
running build
running build_py
running build_ext
building 'mlabraw' extension
Traceback (most recent call last):
  File "setup.py", line 189, in <module>
    extra_compile_args=EXTRA_COMPILE_ARGS,
  File "C:\Python27\lib\distutils\core.py", line 152, in setup
    dist.run_commands()
  File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python27\lib\distutils\command\install.py", line 563, in run
    self.run_command('build')
  File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python27\lib\distutils\command\build.py", line 127, in run
    self.run_command(cmd_name)
  File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python27\lib\distutils\command\build_ext.py", line 340, in run
    self.build_extensions()
  File "C:\Python27\lib\distutils\command\build_ext.py", line 449, in build_exte
nsions
    self.build_extension(ext)
  File "C:\Python27\lib\distutils\command\build_ext.py", line 499, in build_exte
nsion
    depends=ext.depends)
  File "C:\Python27\lib\distutils\msvc9compiler.py", line 474, in compile
    self.initialize()
  File "C:\Python27\lib\distutils\msvc9compiler.py", line 384, in initialize
    vc_env = query_vcvarsall(VERSION, plat_spec)
  File "C:\Python27\lib\distutils\msvc9compiler.py", line 300, in query_vcvarsal
l
    raise ValueError(str(list(result.keys())))
ValueError: [u'path']

In response to various other issues, I've thus far tried the following:

  1. I followed the installation guide posted here
  2. Installed Microsoft VS Express 2010 and SDK version 7.1
  3. Set the SDK C++ compiler to the default in Matlab
  4. Pointed the msvc9compiler.py script (C:\Python27\Lib\distutils\msvc9compiler.py) at the Common Tools folder for my VS Express install in order to avoid an 'unable to locate vcvarsall.bat' error, as described here.

Any help you guys could provide would be greatly appreciated. Many thanks.

Autoharp answered 10/2, 2013 at 23:44 Comment(2)
did you try manually deleting: c:\users\nathan\appdata\local\temp\tmpv tzipcRwanda
Yes. Unfortunately, the setup script seems to create these temporary files whenever it is run, but cannot delete them (even when I run it from an elevated command prompt).Autoharp
S
0

Yes, I am 11 years and 6 months late but I will do my best to answer this question I assume you have already worked out.

It seems the issue you're encountering while setting up mlabwrap on windows is related to compiling python extensions on windows, particularly with the need for the correct visual studio compiler that matches your version of python. Heres what I would recommend you do to fix your issue:

  • Ensure you have the correct compiler version, since you're using python 2.7 you will need the Microsoft visual c++ compiler [download here] whilst I have read that it has been removed from windows in this Stack question.

  • Your error message suggests that other processes are using the tmpvtzipc file. Ensure that no other python or matlab processes are running that may lock the file. You can delete the file contents from C:\Users\[YourUsername]\AppData\Local\Temp if need be.

  • Make sure your environment variables are correctly set. Your visual studio compiler and SDK path should be in your path variable. You can set these paths in your cmd prompt session before running the setup.py script as shown:

    set PATH=C:\Path\To\VC\bin;%PATH%

    set PATH=C:\Path\To\SDK\bin;%PATH%

  • Sometimes running setup.py install cmd as an administrator can help permission issues.

Optional Steps

If none of the prior steps worked, you could use Anaconda or Miniconda which manages packages and dependencies. You can do this by executing the following code:

conda create -n py27 python=2.7
conda activate py27

After that you can try installing mlabwrap.

Another interesting alternative is since mlabwrap is an older tool, you should consider using matlab.engine for python. It basically allows you to call matlab functions directly from python. If this interests you, you can install it using:

pip install matlab.engine

This might be a more straightforward and supported solution if you continue to have difficulties.

Sestos answered 22/8 at 12:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.