Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

arokem
Copy link
Owner

@arokem arokem commented Feb 1, 2015

At least until someone helps us build the messenger for that system.

This should help with #122

At least until someone helps us build the messenger for that system.
@mmagnuski
Copy link

I have a 32-bit python installed (mainly because psychopy declares not to work on 64 bit python) on a 64 bit windows. In this scenario both sys and platform return 32 bit:

import sys
sys.platform
Out[2]: 'win32'

import platform
platform.architecture()
Out[4]: ('32bit', 'WindowsPE')

Checking for maxint also does not work in this context:

maxint = sys.maxint()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-8213151cd894> in <module>()
----> 1 maxint = sys.maxint()

TypeError: 'int' object is not callable

maxint = sys.maxint
maxint
Out[12]: 2147483647

However, checking platform.machine() works well:

platform.machine().endswith('64')
Out[5]: True

So if 32 bit python running on 64 bit windows is ok, I would consider checking system architecture with platform.machine().

@arokem
Copy link
Owner Author

arokem commented Feb 1, 2015

Thanks @mmagnuski for checking this! Does the recent commit work for you?

As you might understand, I don't have a Windows machine to test this on, so I rely heavily on help from people like you!

@mmagnuski
Copy link

I completely understand, windows drives me crazy sometimes. 😄
You forgot to import platform so currently this branch gives an error.
After adding the import pymatbridge installs seemingly well.
However, there is still a problem. mlab.start() brought up a matlab instance window saying:

Invalid MEX-file 'D:\Python\Anaconda\lib\site-packages\pymatbridge\matlab\messenger.mexw64': Nie można odnaleźć określonego modułu.
Error in matlabserver (line 7)
messenger('init', socket_address); 

I would like to help here but I'm not sure if I can - I have never done any C or mex.
Why would the mex file be invalid?
The part of the error that is in polish reads something like "could not find specified module".
Could I be missing something on the matlab part or is it that the pymatbridge mex files were not correclty installed?

@mmagnuski
Copy link

I will try compiling messenger.c to mex in the nex few days (will have to figure how to do it) and see if this helps. But this seems to be unrelated to this pull request, so I think it would be better if I opened a new issue for this Invalid MEX-file error.

@arokem
Copy link
Owner Author

arokem commented Feb 1, 2015

Oh - oops - thanks for pointing that out.

As for your mex error, I sort of know what "nie mozna" means, but what does
the rest mean? :-)

For building the messenger on your system, you might want to refer to these
notes:
http://stackoverflow.com/questions/23716426/installing-pymatbridge-on-windows

On Sun, Feb 1, 2015 at 3:09 PM, mmagnuski [email protected] wrote:

I will try compiling messenger.c to mex in the nex few days (will have to
figure how to do it) and see if this helps. But this seems to be unrelated
to this pull request, so I think it would be better if I opened a new issue
for this Invalid MEX-file error.


Reply to this email directly or view it on GitHub
#123 (comment)
.

@arokem
Copy link
Owner Author

arokem commented Feb 1, 2015

Just to be sure - is this branch ready to merge from your point of view?

On Sun, Feb 1, 2015 at 3:36 PM, Ariel Rokem [email protected] wrote:

Oh - oops - thanks for pointing that out.

As for your mex error, I sort of know what "nie mozna" means, but what
does the rest mean? :-)

For building the messenger on your system, you might want to refer to
these notes:
http://stackoverflow.com/questions/23716426/installing-pymatbridge-on-windows

On Sun, Feb 1, 2015 at 3:09 PM, mmagnuski [email protected]
wrote:

I will try compiling messenger.c to mex in the nex few days (will have to
figure how to do it) and see if this helps. But this seems to be unrelated
to this pull request, so I think it would be better if I opened a new issue
for this Invalid MEX-file error.


Reply to this email directly or view it on GitHub
#123 (comment)
.

@mmagnuski
Copy link

Thanks for the resources, they will be very useful.
(The meaning of the 'nie mozna' error (its in polish) is something like: "could not find specified module").
Yes, I think the installation should work well on 64 bit windows now. Ready to merge, sir! :)

@arokem
Copy link
Owner Author

arokem commented Feb 2, 2015

Hmm. I wonder what module it's referring to.

arokem added a commit that referenced this pull request Feb 2, 2015
BF: Install on Windows 64 systems, but not on 32 bit Windows.
@arokem arokem merged commit bb5a0fc into master Feb 2, 2015
@arokem
Copy link
Owner Author

arokem commented Feb 2, 2015

Just for the record: what is your Matlab version? In case that ends up being a meaningful variable here.

@mmagnuski
Copy link

Sorry for the delay - my matlab version:

MATLAB Version: 8.0.0.783 (R2012b)

I will report soon on my progress :)

@willard-yuan
Copy link

@mmagnuski , I also encountered this type of problem in windows, the error is the same to you:

Invalid MEX-file 'D:\Python\Anaconda\lib\site-packages\pymatbridge\matlab\messenger.mexw64': .
Error in matlabserver (line 7)
messenger('init', socket_address); 

image

The version of my python is as follows:
image

and my matlab version is also MATLAB Version: 8.0.0.783 (R2012b)

I run the package python-matlab-bridge in Ubuntu 14.04 successfully, but the problem in the window 7 still unsolved.

@franktoffel
Copy link

Hi, I am having the same issue with windows 7 and Anaconda:

ValueError: pymatbridge does not work on win32

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\fran
z\AppData\Local\Temp\pip-build-9c9zsay6\pymatbridge

Python 3.4.2:

C:\Users\franz>python
Python 3.4.2 |Continuum Analytics, Inc.| (default, Jan  9 2015, 10:32:40) [MSC v
.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

@arokem
Copy link
Owner Author

arokem commented Mar 3, 2015

First question: are you installing from a recent version of pymatbridge?
If the answer to that question is "yes", what happens if you type the following in a python session?

import sys
print(sys.platform)
import platform
print(platform.machine())

@franktoffel
Copy link

Hi! I've just tried to install pymatbridge via pip so I guess the answer is
"yes".

This is the output I get with the code you mention:

print(sys.platform)
win32

print(platform.machine())
AMD64

On Tue, Mar 3, 2015 at 8:47 PM, Ariel Rokem [email protected]
wrote:

First question: are you installing from a recent version of pymatbridge?
If the answer to that question is "yes", what happens if you type the
following in a python session?

import sys
print(sys.platform)
import platform
print(platform.machine())


Reply to this email directly or view it on GitHub
#123 (comment)
.

Francisco J. Navarro-Brull

@arokem
Copy link
Owner Author

arokem commented Mar 3, 2015

That confuses me. Would you mind trying to install this from the source?

That would entail downloading the current source code (https://github.com/arokem/python-matlab-bridge/archive/master.zip) and running

python setup.py install 

in the source directory.

@franktoffel
Copy link

Ok, from source it worked :)

But... now I get this in the MATLAB console (I am watching the conversations here because same problem happened before)

Matlab version R2013a

Invalid MEX-file

'C:\Users\franz\Anaconda3\envs\imatlab\lib\site-packages\pymatbridge\matlab\messenger.mexw64':
The specified module
could not be found.

@arokem
Copy link
Owner Author

arokem commented Mar 3, 2015

Well, progress, but so sorry that it isn't working yet. This might be an
issue with the version of zmq that you have installed.

Could you please tell me what you get when you type:

import zmq
print(zmq.zmq_version())

Hey @blink1073 - could you confirm that this was built against zmq3? Do you
still have access to the machine on which you built the Windows messenger?
Maybe we could build the zmq4 ones for this platform as well?

There's this page on SO, describing how to build the messenger yourself on
Windows, but I am not sure that it's up-to-date:

http://stackoverflow.com/questions/23716426/installing-pymatbridge-on-windows

On Tue, Mar 3, 2015 at 1:00 PM, Fran Navarro [email protected]
wrote:

Ok, from source worked :)

But... now I get this in the MATLAB console :(

Invalid MEX-file

'C:\Users\franz\Anaconda3\envs\imatlab\lib\site-packages\pymatbridge\matlab\messenger.mexw64':
The specified module
could not be found.

On Tue, Mar 3, 2015 at 9:36 PM, Ariel Rokem [email protected]
wrote:

That confuses me. Would you mind trying to install this from the source?

That would entail downloading the current source code (
https://github.com/arokem/python-matlab-bridge/archive/master.zip) and
running

python setup.py install

in the source directory.


Reply to this email directly or view it on GitHub
<
#123 (comment)

.

Francisco J. Navarro-Brull


Reply to this email directly or view it on GitHub
#123 (comment)
.

@franktoffel
Copy link

print(zmq.zmq_version())
4.0.5

is that a problem?

@blink1073
Copy link
Collaborator

@arokem, I did not build the Matlab mex for Windows, since I only have a Linux version.

@arokem
Copy link
Owner Author

arokem commented Mar 3, 2015

Indeed, it looks like @aebrahim did that here:
ca59b30

If you're still around, @aebrahim: could we ask for your help building the
Windows messenger with zmq 4?

Although, how did you get the Octave messenger for Windows, without a
Windows machine?
https://github.com/arokem/python-matlab-bridge/blob/master/messenger/mexw64/messenger.mex

On Tue, Mar 3, 2015 at 3:38 PM, Steven Silvester [email protected]
wrote:

@arokem https://github.com/arokem, I did not build the Matlab mex for
Windows, since I only have a Linux version.


Reply to this email directly or view it on GitHub
#123 (comment)
.

@aebrahim
Copy link
Contributor

aebrahim commented Mar 3, 2015

I'll take a crack at that this weekend.

@blink1073
Copy link
Collaborator

@arokem, I have a Windows machine, just no Windows Matlab. 😄

@arokem
Copy link
Owner Author

arokem commented Mar 4, 2015

Aha! Of course - that explains. Oh well, let's wait for @aebrahim to take a
shot at this (thanks for the swift reply, and TIA for taking a crack at
it!).

On Tue, Mar 3, 2015 at 5:50 PM, Steven Silvester [email protected]
wrote:

@arokem https://github.com/arokem, I have a Windows machine, just no
Windows Matlab. [image: 😄]


Reply to this email directly or view it on GitHub
#123 (comment)
.

@arokem
Copy link
Owner Author

arokem commented Mar 9, 2015

Hey @aebrahim - any luck with this?

@aebrahim
Copy link
Contributor

aebrahim commented Mar 9, 2015

Sorry for the delay. See #161

@arokem
Copy link
Owner Author

arokem commented Mar 10, 2015

@franktoffel - this is now merged into master, could you try reinstalling from master?

@franktoffel
Copy link

Hi @arokem, I have just tried the installation from master (the installation worked fine). I am still unable to connect due to a problem with the mex files (albeit these files exist). This is the error I've got on the matlab command window:

Invalid MEX-file 'C:\Users\franz\Anaconda3\envs\imatlab\lib\site-packages\pymatbridge\matlab\messenger.mexw64': The specified procedure
could not be found.

@mmagnuski
Copy link

I am having the same error. Installed from master, installation was ok but mex still does not work.

@aebrahim
Copy link
Contributor

Ok. Strange because it worked for me. What matlab version?
On Mar 11, 2015 6:08 AM, "mmagnuski" [email protected] wrote:

I am having the same error. Installed from master, installation was ok but
mex still does not work.


Reply to this email directly or view it on GitHub
#123 (comment)
.

@mmagnuski
Copy link

My matlab version:

>> version
ans =
8.0.0.783 (R2012b)

My zmq version:

print(zmq.zmq_version())
4.0.5

I have 64 bit windows 8 and 32 bit python (2.7) - I am not sure if this is relevant, but try to always mention it just to be on the safe side.

@aebrahim
Copy link
Contributor

Did MATLAB break some binary compatibility or something? I have the
opposite problem you do - I can use the new mex but not the old mex on
R2014b.

On Wed, Mar 11, 2015 at 9:39 AM, mmagnuski [email protected] wrote:

My matlab version:

version
ans =
8.0.0.783 (R2012b)

My zmq version:

print(zmq.zmq_version())4.0.5

I have 64 bit windows 8 and 32 bit python (2.7) - I am not sure if this is
relevant, but try to always mention it just to be on the safe side.


Reply to this email directly or view it on GitHub
#123 (comment)
.

@aebrahim
Copy link
Contributor

In fact, it runs for me in R2014b but not R2013a.

On Wed, Mar 11, 2015 at 9:56 AM, Ali Ebrahim [email protected] wrote:

Did MATLAB break some binary compatibility or something? I have the
opposite problem you do - I can use the new mex but not the old mex on
R2014b.

On Wed, Mar 11, 2015 at 9:39 AM, mmagnuski [email protected]
wrote:

My matlab version:

version
ans =
8.0.0.783 (R2012b)

My zmq version:

print(zmq.zmq_version())4.0.5

I have 64 bit windows 8 and 32 bit python (2.7) - I am not sure if this
is relevant, but try to always mention it just to be on the safe side.


Reply to this email directly or view it on GitHub
#123 (comment)
.

@aebrahim
Copy link
Contributor

I built this with 2013a... does it work any better?

https://drosophi.la/messenger.mexw64

On Wed, Mar 11, 2015 at 10:12 AM, Ali Ebrahim [email protected] wrote:

In fact, it runs for me in R2014b but not R2013a.

On Wed, Mar 11, 2015 at 9:56 AM, Ali Ebrahim [email protected] wrote:

Did MATLAB break some binary compatibility or something? I have the
opposite problem you do - I can use the new mex but not the old mex on
R2014b.

On Wed, Mar 11, 2015 at 9:39 AM, mmagnuski [email protected]
wrote:

My matlab version:

version
ans =
8.0.0.783 (R2012b)

My zmq version:

print(zmq.zmq_version())4.0.5

I have 64 bit windows 8 and 32 bit python (2.7) - I am not sure if this
is relevant, but try to always mention it just to be on the safe side.


Reply to this email directly or view it on GitHub
#123 (comment)
.

@franktoffel
Copy link

With R2014a (Classroom license) didn't work before. I didn't try with your mex file, @aebrahim

@mmagnuski
Copy link

Matlab 2014b changes the way handles work in graphics and generally redesigns graphic internals, but I am not aware if this entails binary incompatibility.

Regarding the mex file - it works! 🐹 👍
So while I am really happy the mex works for me, the code still throws an error.
I got Matlab failed to start. error, but matlab did start and seems to be connected (matlab window says Socket created at: tcp://127.0.0.1:55555).
Matlab startup was (and usually is) pretty slow, so I thought that maybe pymatbridge does not wait long enough for the connection to be established?
The problem may be in this part of is_connected method:

def is_connected(self):
        if not self.started:
            time.sleep(2)
            return False

What is the time.sleep supposed to do here? Maybe the intent was to sleep for some time and check again? Currently it sleeps and returns False anyway.

@mmagnuski
Copy link

A success (with yet another error :) ):

  • I restart the kernal
  • I leave previously opened matlab window open
  • I start python-matlab connection:
from pymatbridge import Matlab
mlab = Matlab()
mlab.start()

This quickly connects to matlab (probably because one matlab instance was connected to the socket already) and everything works (run_code, get_variable etc.)
BUT pymatbridge spawned another matlab instance that failed to connect, the error in matlab window says:

Error using messenger
Socket creation failed.
Error in matlabserver (line 7)
messenger('init', socket_address); 

So it may be useful not to spawn another matlab instance in this case (although it is harmless).

Anyway - the mex file works, and python and matlab can finally speak to each other. 👯

@mmagnuski
Copy link

Just to clarify which mex works for me - the one built on matlab 2013b by @aebrahim

@mmagnuski
Copy link

(BTW - %load_ext pymatbridge also creates another matlab instance, although one connected is already present. It probably requires another issue)

@aebrahim
Copy link
Contributor

OK I'll create a pull request using the new file.

On Wed, Mar 11, 2015 at 2:04 PM, mmagnuski [email protected] wrote:

(BTW - %load_ext pymatbridge also creates another matlab instance,
although one connected is already present. It probably requires another
issue)


Reply to this email directly or view it on GitHub
#123 (comment)
.

@aebrahim
Copy link
Contributor

Wait there never was a 2013b. There is 2013a and 2014b. Which did you mean?

On Wed, Mar 11, 2015 at 2:09 PM, Ali Ebrahim [email protected] wrote:

OK I'll create a pull request using the new file.

On Wed, Mar 11, 2015 at 2:04 PM, mmagnuski [email protected]
wrote:

(BTW - %load_ext pymatbridge also creates another matlab instance,
although one connected is already present. It probably requires another
issue)


Reply to this email directly or view it on GitHub
#123 (comment)
.

@mmagnuski
Copy link

Sorry, 2013a.

@DeepGravity
Copy link

Hi,
I'm from 2020.

I have the same issue. and followed all mentioned tricks, but it did not work.

this is my error:

CalledProcessError: Command '['C:\Program Files\MATLAB\R2019a\bin\mex', '-O', '-LC:\Users\USER\Anaconda3\pkgs\zeromq-4.3.2-h6538335_2\Library\lib', '-IC:\Users\USER\Anaconda3\pkgs\zeromq-4.3.2-h6538335_2\Library\include', '-lzmq', './src/messenger.c', '-DZMQ_STATIC']' returned non-zero exit status 4294967295.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants