Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Undefined variable "py" or class" when trying to load Python from MATLAB R2014b?

Tags:

python

matlab

def c1(a1,b1):
    a1=2
    b1=3
    cc=a1+b1
    return cc

I have saved this function in test.py. When I use this function in MATLAB I encountered this problem:

import py.test.* c1(2,3)
Undefined function 'c1' for input arguments
of type 'double'.
  py.test.c1(2,3)
Undefined variable "py" or class
"py.test.c1".

How can I use .py function in MATLAB R2014b?

like image 982
xiaobai1217 Avatar asked Mar 05 '26 02:03

xiaobai1217


1 Answers

If you get the error message below, a failure has occurred.

Undefined variable "py" or class

There are a lot of things that might be wrong here, and Mathworks have actually set up a whole tutorial for how to troubleshoot this problem. (The title of the page is actually: Undefined variable "py" or function "py.command", so it should contain most of what you need)

Check out the following:

  • Python Not Installed
  • 64-bit/32-bit Versions of Python on Windows Platforms
  • MATLAB Cannot Find Python
  • Error in User-Defined Python Module
  • Python Module Not on Python Search Path
  • Module Name Conflicts
  • Python Tries to Execute command in Wrong Module
like image 102
Stewie Griffin Avatar answered Mar 07 '26 15:03

Stewie Griffin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!